I am using jmap utility to calculate correct size of heap space size of JVM. The purpose is to have it scripted so I can pass it to the graph builder automatically.
Here is calculation approach I use.
The output of jmap consist of several lines of "used =" patterns. These a get summed and Eden space size deducted from the sum, because, as far as I understand, it is already used by first line.
Here is number of questions:
How to calculate (using jmap) total space JVM is allocating?
Is my approach right? (I ask because one of JVMs I have show peak values slightly higher then MaxHeapSize. I just think that my formula is not 100% accurate.)
Here is the example. Green bold lines are values for "used" space:
# ./jmap -heap 24373
Attaching to process ID 24373, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 17.1-b03
using parallel threads in the new generation.
using thread-local object allocation.
Concurrent Mark-Sweep GC
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 4049600512 (3862.0MB)
NewSize = 1619001344 (1544.0MB)
MaxNewSize = 1619001344 (1544.0MB)
OldSize = 5439488 (5.1875MB)
NewRatio = 2
SurvivorRatio = 8
PermSize = 268435456 (256.0MB)
MaxPermSize = 524288000 (500.0MB)
Heap Usage:
New Generation (Eden + 1 Survivor Space):
capacity = 1457127424 (1389.625MB)
used = 513245488 (489.4690399169922MB)
free = 943881936 (900.1559600830078MB)
35.223102629629736% used
Eden Space:
capacity = 1295253504 (1235.25MB)
used = 468607480 (446.89891815185547MB)
free = 826646024 (788.3510818481445MB)
36.178823570277714% used
From Space:
capacity = 161873920 (154.375MB)
used = 44638008 (42.57012176513672MB)
free = 117235912 (111.80487823486328MB)
27.575787378226213% used
To Space:
capacity = 161873920 (154.375MB)
used = 0 (0.0MB)
free = 161873920 (154.375MB)
0.0% used
concurrent mark-sweep generation:
capacity = 2430599168 (2318.0MB)
used = 674948688 (643.6812286376953MB)
free = 1755650480 (1674.3187713623047MB)
27.76881918195407% used
Perm Generation:
capacity = 374423552 (357.078125MB)
used = 211131088 (201.3502960205078MB)
free = 163292464 (155.7278289794922MB)
56.3883032657091% used
Leonid