Search code examples
javamemory-leaksjvmprofilingjprofiler

Profiling JVM: Committed vs Used vs free Memory


I'm profiling a Java application deployed to Jetty server, using JProfiler.

After a while, I'm getting this memory telemetry: enter image description here

On the right side is the total memory of this Java process on Windows Task Manager.

  1. I see periodic increases in the Committed Memory in JProfiler, although most of the time, most of this memory is Free (Green). Why is the committed memory increased like this?
  2. In the time point when the image above was taken, the Committed Memory in JProfiler shows 3.17GB but Windows Task Manager shows much higher - 4.2457 GB. Isn't it the same memory they both show? What might be the reason for this difference?

Solution

  • If the peak memory usage approaches the total committed memory size, the JVM will increase the committed memory (the memory that has actually been reserved by the OS for the process) as long as your -Xmx value allows it.

    This is a little like filling an ArrayList. When the backing array is exhausted, it's enlarged in larger and larger steps, so that it does not have to be resized for each insert.

    As for the difference between the task manager and the heap size of the JVM, the memory in the task manager is always larger than the heap size and is generally difficult to interpret. See here for an explanation of the different measures:

    https://technet.microsoft.com/en-us/library/ff382715.aspx