Java is becoming smarter with a new experimental change in OpenJDK 9 that can detect a container environment to adjust memory limits intelligently. The new development will reduce the out of memory instances and deliver a smoother experience on container technologies through the upcoming Java 9 release.
Containers play a major role in memory allocation while building a project. However, many tools are still reliant on host parameters to assess available resources. Developers are using container technologies and lightweight Linux-powered virtual machines to work on various tasks simultaneously.
But if you do not mention the maximum memory limit on any virtual machines, even if it is a JVM (Java Virtual Machine), by default a fraction of physical memory will be consumed for your tasks.
The new change in OpenJDK 9 is designed to prevent this problem by checking if JVM is running in cgroup. If the virtual machine is running within cgroup, it will find the memory limit and consider it as available physical memory. This alters the space consumption on the basis of available container technology.
The new function within OpenJDK 9 is available in the experimental stage. However, you can test its presence by activating it using command —XX:+UseCGroupMemoryLimitForHeap.