Parsing the details of the 2GB limit for JVM memory in a Linux system

  • 2020-04-01 01:58:56
  • OfStack

We typically use 32-bit JVMS (64-bit JVMS lose 10-20% of their performance and are generally not recommended), and 32-bit programs should have 4GB of addressing space, so why only 2GB of JVM memory on Linux?

After talking to the JDK development team, we finally figured out some of the relevant reasons. This problem existed in some early versions of Linux, especially before kernel 2.5, and has been largely absent since 2.6. It turns out that these Linux versions have a 2GB memory limit for processes, which is the maximum size of a contiguous block of memory for an address, whereas the heap size of the JVM requires contiguous address space, so 2GB is the theoretical memory limit for Java processes.

If Java applications require large amounts of memory, it is recommended to use a newer version of Linux, or to modify the Linux application/kernel memory ratio configuration to 3GB: 1GB. There is also the choice of UNIX operating systems such as Solaris. Operating systems like Solaris have no 2GB limit on JVM memory management, so you can set the heap size to around 3.5-3.6gb.

 


Related articles: