I just wanted to know what the actual footprint of the JavaVM (Sun, Linux) is when one starts to start to spawn multiple processes of JVMs. When I remember well those should share the rt.jar (and maybe beyond?). Does those JVM share the JIT cache (all JVM feature the same Classpath)?
Is there anything I can do to reduce the overhead of multi-instance JVM? (beside of setting smaller limits for the heap)?
Anything I can do while programming the application?
Can I share memory areas? Maybe share mapped memory blocks?
In a Java program, the memory footprint is predominantly made up of the runtime environment in the form of Java virtual machine (JVM) itself that is loaded indirectly when a Java application launches.
Set the Heap Size The most obvious place to start tuning the memory footprint is the Java heap size. If you reduce the Java heap size by a certain amount you will reduce the memory footprint of the Java process by the same amount. You can however not reduce the Java heap size infinitely.
An interesting area when sizing the JVM is the JIT's code cache. By default, the HotSpot JVM will use up to 240MB. If the code cache is too small the JIT will run out of space to store its output and performance will suffer as a result. If the cache is too large, memory may be wasted.
To complement other answers, here is a couple of insightful articles listing typical JVM memory footprint values and ways to measure them:
https://spring.io/blog/2015/12/10/spring-boot-memory-performance
http://trustmeiamadeveloper.com/2016/03/18/where-is-my-memory-java/
Probably it will be only a partial answer.
What is the memory footprint of the JVM
The full footprint of a Java app consists of Heap space and non-heap space (let me call it this way). Just a couple of examples of what resides in non-heap space: PermGen or Metaspace, derect allocation from code (malloc), NIO also uses native memeory.
how can I minimize it?
The heap usually occupies the biggest part of you footprint. So, I would start with it.
As for the non-heap space, you can minimize: PermGen (If you max size is redundant), Thread stacks (They are quite large, especially in 64-bit JMMs) and Code cache (insted of performance, of course).
Does those JVM share the JIT cache
In normal conditions (and I'm not aware of others) every process has its own footprint. That's actually what differs a process from a thread. And back to multiple JVMs, each JVM is a separate process.
should share the rt.jar
If you start Java from the same directory (the same installation), of course, they share the same rt.jar, but only as a source of classes. For example, the String class will be loaded as many times as a number of running JVMs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With