Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?
like image 990
Forepick Avatar asked Jun 21 '18 10:06

Forepick


People also ask

What is JVM memory committed?

From the javadocs, committed is: The amount of memory (in bytes) that is guaranteed to be available for use by the Java virtual machine. The amount of committed memory may change over time (increase or decrease). The Java virtual machine may release memory to the system and committed could be less than init.

What is the use of committed () method of Memoryusage object?

committed will always be greater than or equal to used. represents the maximum amount of memory (in bytes) that can be used for memory management. Its value may be undefined. The maximum amount of memory may change over time if defined.

What is committed memory in Jconsole?

4. Committed Size. The committed size is the amount of memory guaranteed to be available for use by the Java virtual machine. The committed memory size is always greater than or equal to the used size.

How is JVM memory allocated?

JVMs allocate memory on an as needed basis from the operating system. Generally, when the JVM starts, it will allocate the minimum memory allocated (Xms) to the application that is running. As the application requires more memory, it will allocate blocks of memory until the maximum allocation (Xmx) has been reach.


1 Answers

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

like image 133
Ingo Kegel Avatar answered Sep 29 '22 22:09

Ingo Kegel