What is the memory footprint of the JVM and how can I minimize it?

Martin Kersten picture Martin Kersten · Jul 24, 2016 · Viewed 13.2k times · Source

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?

Answer

apangin picture apangin · Jul 24, 2016

This post describes what makes up a Java application footprint. That is, if you want to reduce footprint, you need to reduce those parts: Java Heap, Metaspace, Code Cache, direct buffers, number of threads etc.

Instances of HotSpot JVM do not communicate to each other for sharing data. Basically they share nothing except for the things shared by the OS, i.e. the dynamic libraries (.so) and read-only memory-mapped files (.jars).

It's up to the application to provide further sharing via IPC mechanisms, e.g. memory-mapped files.