Difference in Used, Committed and Max Heap Memory

Alok picture Alok · Jan 4, 2017 · Viewed 35.3k times · Source

I am monitoring a spark executor JVM of a OutOfMemoryException. I used Jconsole to connect to executor JVM. Following is the snapshot of Jconsole: enter image description here

In the image used memory is shown as 3.8G and committed memory is 8.6G and Max memory is also 8.6G Could anyone explain the difference between Used and Committed Memory or any link which explains it.

Answer

musibs picture musibs · Sep 20, 2017

From the Java Doc of MemoryUsage,

getUsed is:

the amount of used memory in bytes

getCommitted()

Returns the amount of memory in bytes that is committed for the Java virtual machine to use. This amount of memory is guaranteed for the Java virtual machine to use.

getMax()

Returns the maximum amount of memory in bytes that can be used for memory management. This method returns -1 if the maximum memory size is undefined.

This amount of memory is not guaranteed to be available for memory management if it is greater than the amount of committed memory. The Java virtual machine may fail to allocate memory even if the amount of used memory does not exceed this maximum size.