View RSS Feed

lovelesh

jmap - jdk provided heap observation utility

Rating: 2 votes, 4.00 average.
by , 06-25-2011 at 01:15 PM (5059 Views)
jmap is one of the lesser known jdk provided utilities, which are worth mentioning. Very oftenly we feel the need to peek into the jvm and see which thread is taking how much of heap space - jmap is jdk’s answer to this.

This utility was introduced in jdk1.5 and is as an experimental utility (oracle may discontinue to ship this utility with future releases)

Some of the notable features of jmap are:

1. can print shared object memory maps or heap memory details of a given process.
2. provides information about objects which are ready to be finalized.
3. provides information about heap configuration and algorithm used for Garbage Collection.
4. provides option to get information about loaded classes like, number of objects created, memory size in bytes, etc.
5. allows dumping of heap related info in binary file format. This file can be viewed with other jdk provided utilities like, jhat.
6. can provide statistical data related to associated class loaders.

Usage:

jmap [ option ] pid
jmap [ option ] executable core
jmap [ option ] [server-id@]remote-hostname-or-IP

Options:

<no option>
When no option is used jmap prints shared object mappings. For each shared object loaded in the target VM, start address, the size of the mapping, and the full path of the shared object file are printed. This is similar to the Solaris pmap utility.

-dump:[live,]format=b,file=<filename>
Dumps the Java heap in hprof binary format to filename. The live suboption is optional. If specified, only the live objects in the heap are dumped. To browse the heap dump, you can use jhat (Java Heap Analysis Tool) to read the generated file.

-finalizerinfo
Prints information on objects awaiting finalization.

-heap
Prints a heap summary. GC algorithm used, heap configuration and generation wise heap usage are printed.

-histo[:live]
Prints a histogram of the heap. For each Java class, number of objects, memory size in bytes, and fully qualified class names are printed. VM internal class names are printed with '*' prefix. If the live suboption is specified, only live objects are counted.

-permstat
Prints class loader wise statistics of permanent generation of Java heap. For each class loader, its name, liveness, address, parent class loader, and the number and size of classes it has loaded are printed. In addition, the number and size of interned Strings are printed.

-F
Force. Use with jmap -dump or jmap -histo option if the pid does not respond. The live suboption is not supported in this mode.

-h
Prints a help message.

-help
Prints a help message.

-J<flag>
Passes <flag> to the Java virtual machine on which jmap is run

Example:

cmd> jmap -heap 1234

Attaching to process ID 1234, please wait...
…........
…........
JVM version is 1.6.0_13-b03

using parallel threads in the new generation.
using thread-local object allocation.
Concurrent Mark-Sweep GC
…............................
…............................
…............................

Submit "jmap - jdk provided heap observation utility" to Facebook Submit "jmap - jdk provided heap observation utility" to Digg Submit "jmap - jdk provided heap observation utility" to del.icio.us Submit "jmap - jdk provided heap observation utility" to StumbleUpon Submit "jmap - jdk provided heap observation utility" to Google

Tags: None Add / Edit Tags
Categories
Uncategorized

Comments