I don’t think Java needs visibility into the max memory, as you need to set it via args (-Xmx) if you want a max - otherwise it will just keep allocation as it needs it - if an allocation from the OS fails, it will attempt a final GC to see if it can get more room, and if not, OOME.
The Runtime.maxMemory() returns the configured max, not the OS max limit. > On Sep 12, 2018, at 1:48 AM, Leigh McCulloch <leigh...@gmail.com> wrote: > > Hi, > > 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.) > > Thanks, > Leigh > > -- > 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. -- 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.