5

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?
Forepick
  • 919
  • 2
  • 11
  • 31
  • 5
    The task manager doesn’t know anything about “heap memory”. It always shows the total memory, heap, stack, code, non-heap data, buffers, etc. – Holger Jun 21 '18 at 10:44
  • 1
    The JVM needs memory for a number of other purposes than purely the heap. – Peter Lawrey Jun 25 '18 at 09:41

1 Answers1

9

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

Ingo Kegel
  • 46,523
  • 10
  • 71
  • 102