0

We have two processes (p1 and p2) in a JVM container (in Docker) using kubernetes.

The resource Limit (in the helm chart) for the container is set to 1000 MiB.

We set the XX:MaxRAMPercentage to 50% (=500 MiB). How will the heap distribution for each process look like?

Will they p1 and p2 equally so they will have 250 MiB each that cannot be exceeded?

Or will they share the whole heap of 500 MiB that cannot be exceeded?

derkoe
  • 5,649
  • 2
  • 23
  • 31

1 Answers1

0

The heap memory is just a part of the memory consumed by the JVM - there is also stack and native memory; the runtime, the JIT and the garbage collector also need memory. So, a typical Java application run with -Xmx500m will need approximately 700-1000MB of RAM (when using the full heap). The full memory usage heavily depends on what your application is doing and how it allocates and deallocates memory - some Java apps with 1GB of heap can use 20GB of RAM.

Back to your question: when you limit the container to 1000MiB and run two same-siced, pretty standard Java web applications, I would size the JVMs with -Xmx300m (or if you really want to use relative values: -XX:MaxRAMPercentage=30.0).

For more information: this answer gives a good overview of Java memory.

derkoe
  • 5,649
  • 2
  • 23
  • 31