JVM Tools – JMAP


JMAP

The Java jmap utility provides a number of useful options to summarize heap usage, and get a break down of objects in the new and old generations. To summarize the new and old generations, the jmap utility can be run with the “-heap” option, and the PID of the JVM to summarize (the PID can be acquired by running the jps utility, or by reviewing the ps output):

Usage: jmap [ option ] pid
jmap [ option ] executable core

General Options include:

# jmap -heap prints heap usage, gc algorithm and heap configuration details.
# jmap -histo prints a histogram of the current heap or core (class, number of instances, and the total number of bytes used by all the instances together).
# jmap -permstat prints details of the perm space contents.
# jmap -permgen prints statistics for the objects in the permanent generation, including information about internalized String instances.

>jmap -heap `pgrep java`
Attaching to process ID 5365, please wait…
Debugger attached successfully.
Server compiler detec ted.
JVM version is 1.6.0_01 -b06
using parallel threads in the new generation.
using thread-local object allocation.
Concurrent Mark -Sweep GC
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 1073741824 (1024.0MB)
NewSize = 268435456 (256.0MB)
MaxNewSize = 268435456 (256.0MB)
OldSize = 805306368 (768.0MB)
NewRatio = 7
SurvivorRatio = 6
PermSize = 21757952 (20.75MB)
MaxPermSize = 88080384 (84.0MB)
Heap Usage:
New Generation (Eden + 1 Survivor Space):
capacity = 234881024 (224.0MB)
used = 102062424 (97.33431243896484MB)
free = 132818600 (126.66568756103516MB)
43.452818053109304% used

Eden Space:
capacity = 201326592 (192.0MB)
used = 94318424 (89.94905853271484MB)
free = 107008168 (102.05094146728516MB)
46.84846798578898% used
From Space:
capacity = 33554432 (32.0MB)
used = 7744000 (7.38525390625MB)
free = 25810432 (24.61474609375MB)
23.07891845703125% used
To Space:
capacity = 33554432 (32.0MB)
used = 0 (0.0MB)
free = 33554432 (32.0MB)
0.0% used
concurrent mark -sweep generation:
capacity = 805306368 (768.0MB)
used = 15032688 (14.336288452148438MB)
free = 7 90273680 (753.6637115478516MB)
1.8667042255401611% used
Perm Generation:
capacity = 50577408 (48.234375MB)
used = 30285240 (28.88225555419922MB)
free = 20292168 (19.35211944580078MB)
59.87898786746842% used

The jmap output contains the size of eden (the place where new objects are created), each survivor space, the old generation and the permanent generation.

In addition to printing summary data, jmap can also be used to display the objects in the heap.

image

This summary contains the type of each object (e.g., “[C” would refer to arrays of  characters), the number of objects of each type as well as the total number of bytes these objects take up in the heap.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s