Understanding IDE memory allocation

 

Sometimes you can observe that the IDE consumes more RAM than you have allowed with the Xmx value in the .vmoptions file.
For a variety of reasons and possible optimizations, the Java Virtual Machine (that the IDE is running on) may allocate extra native memory.
The JVM overhead can range from just a few percent to several hundred. It is not possible to predict how much memory the IDE would realistically allocate with reasonable precision. It can be roughly calculated using this formula:

 

Xmx size + ReservedCodeCacheSize + Metaspace (dynamic) + 8 * 2 (Xss size (2M by default) * threads) + off-heap allocations via ByteBuffers + JNI code



Metaspace is the runtime representation of Java classes within a JVM process - basically, any information the JVM needs to work with a Java class. 

ReservedCodeCacheSize is the amount of memory allocated for the JIT compiler code cache.

threads - 30, typically.

ByteBuffer allows allocating memory outside of the Java heap, which can reduce the load on the garbage collector. The IDE uses ByteBuffers as an intermediate cache when accessing its indices, among other things.

JNI is a Java Native Interface: code natively compiled for a specific architecture, shared libs within .so/.dll/.dylib files (depending on the operating system you’re running).



You can find more detailed information on the topic here:

https://plumbr.io/blog/memory-leaks/why-does-my-java-process-consume-more-memory-than-xmx

https://www.baeldung.com/jni

https://www.baeldung.com/java-permgen-metaspace

https://www.baeldung.com/native-memory-tracking-in-jvm

https://stuefe.de/posts/metaspace/what-is-metaspace/

6 out of 16 found this helpful

Please sign in to leave a comment.

Have more questions?

Submit a request