| ▲ | gavinray a day ago | ||||||||||||||||
Modern JVM's (JDK +10) have runtime detection for whether they're operating in a container environment, and apply sensible defaults based dynamically on resources if so. Google term: "-XX:+UseContainerSupport" | |||||||||||||||||
| ▲ | hibikir a day ago | parent | next [-] | ||||||||||||||||
While you are replying to someone that definitely knows this, you'd be surprised by the number of production containers out there, in big companies, that haven't turned on container support, or hand tuned their memory well, and thus end up throwing away large parts of the memory they are allocated. Having used Java since the days where you needed to do very heavy tuning to get it to run properly, it all seems alien, as understanding the old garbage collectors was basically mandatory 20 year ago. But even if you reply to someone that does understand the new features, you might be helping a bunch of people that don't. In my unit of about 100 programmers I am the only one that even bothered looking, given how every single pod we deployed was either completely unconfigured, or so badly misconfigured, using settings that haven't been ideal since Java 6. In one of the pods, running a batch job that was using way too much memory, about a third of the memory in the old generation were millions of copies of the very same string. Interning of strings loaded like that has been a JVM option since 2014. | |||||||||||||||||
| |||||||||||||||||
| ▲ | brunoborges 19 hours ago | parent | prev | next [-] | ||||||||||||||||
When cgroups / container awareness was added to OpenJDK, it was not on by default, and indeed there were versions that needed this flag. However, all modern JDKs 11 and later, have container awareness support on by default. That said, this only makes the HotSpot JVM use cgroups data to interpret CPU and Memory limits. It does not make any special consideration of default ergonomics (thread pools, GC selection, heap sizing, and so on). Before the container awareness support, the JDK would read the VM/bare metal data; in other words, pre-container awareness support would result in this: if the VM has 32GB of RAM and a container is set for 4GB of memory limit, the JVM reads the 32GB as available memory. All the defaults I mentioned still apply even inside a container. Edit: no worries! thanks for sharing! | |||||||||||||||||
| ▲ | gavinray a day ago | parent | prev | next [-] | ||||||||||||||||
I just realized the username of the comment I replied to. The OP undoubtedly knows this, whoops. | |||||||||||||||||
| |||||||||||||||||
| ▲ | vips7L 21 hours ago | parent | prev [-] | ||||||||||||||||
Isn’t that on by default? | |||||||||||||||||
| |||||||||||||||||