How much memory is the JVM and how can it be minimized?

I just wanted to find out what the actual JavaVM trail (Sun, Linux) is when you start running several JVM processes. When I remember well, they should share rt.jar (or maybe more?). Do these JVMs support JIT cache (all JVMs have the same class path)?

Is there anything I can do to reduce the overhead of a multi-instance JVM? (besides setting smaller heap limits)?

What can I do when programming an application?

Can I use memory areas? Maybe shared memory blocks?

+7
java memory jvm memory-footprint
source share
3 answers

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

JVM HotSpot instances do not tell each other about the exchange of data. Basically, they have nothing in common except common for the OS, that is, dynamic libraries (.so) and files with read-only display (.jars).

This application is to provide further sharing through the IPC mechanisms, for example. memory mapped files.

+5
source share

This will probably be only a partial answer.

What is the memory area of ​​the JVM

The full fingerprint of a Java application consists of heap space and space without heap (let me call it that). Just a few examples of what is in heap-free space: PermGen or Metaspace, allocate code selection (malloc), NIO also uses its own memeory.

How can I minimize it?

A heap usually occupies the largest part of your footprint. So, I would start with this.

As for space without heap, you can minimize: PermGen (if the maximum size is redundant), stream stacks (they are quite large, especially in 64-bit JMMs) and code cache (subject to performance, of course).

Do these JVMs support JIT caching?

Under normal conditions (and I do not know others), each process has its own footprint. This is actually what distinguishes a process from a thread. And back to multiple JVMs, each JVM is a separate process.

should share rt.jar

If you run Java from the same directory (same installation), they, of course, have the same rt.jar, but only as the source of the classes. For example, the String class will load as many times as the number of running JVMs.

+3
source share

In addition to other answers, here are a couple of insightful articles that list typical JVM memory size values ​​and how 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/

+2
source share

All Articles