On Tue, Sep 11, 2018 at 11:48 PM, Leigh McCulloch <leigh...@gmail.com> wrote: > > Does anyone here know how Go interacts with memory limits inside containers? > (e.g. Kubernetes, Docker) > > Does the Go runtime have similar problems as the Java runtime, in that it > doesn't know what the container limit is, and only knows what the physical > limit is for the entire instance? > > Or is Go aware of limits placed on the container? > > (I've witnessed the Go runtime package say the NumCPU is the total physical > count when the app has been limited to many less CPUs, so it seems like it > doesn't have visibility into the CPU limitations.)
As far as I know, the current implementations of Go don't pay attention to memory limits at all, whether running inside a container or not. You may be interested in following https://golang.org/issue/23044 which could be a first step toward fixing this. In some sense the core issue is that using memory limits in a garbage collected language is close to useless if the program doesn't have a way to react when heap size is nearing the memory limit. On the other hand, on GNU/Linux systems, the CPU count is determined by calling the sched_getaffinity system call, which as far as I know is aware of container limits. What leads you to believe otherwise? Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.