In this article we are going to see the jmap commands.
What is jmap?
jmap prints shared object memory maps/heap memory details of a given process/core file/a remote debug server. Jmap stands for java memory map.
Syntax
jmap [option] pId
jmap [option] exe core
jmap [option] [server-id@]remote-hostname-or-IP
In here :
- pId = Java process id (use jps to get the info)
- exe = Java executable from which the core dump was produced.
- core = Core file for which the stack trace is to be printed.
- remote-hostname-or-IP = Debug server’s (see jsadebugd) hostname or IP address.
- server-id= (optional) unique server id
jmap Options :
With no option is used jmap prints shared object mappings. This is similar to the Solaris pmap utility.
- dump:[live], format=b,file=filename : Dumps the Java heap in hprof binary format to filename.
- live : objects in the heap are dumped(optional).
- format=b : Binary default
- file=filename : dump heap to filename
- finalizerinfo : Prints information on objects awaiting finalization.
- heap : Prints a heap summary(GC algorithm ,heap configuration ,generation wise heap)
- histo[:live] : Prints a histogram of the heap.
- permstat :Prints class loader wise statistics of permanent generation of Java heap( the number and size of interned Strings are also printed)
- F : Force(Use with jmap -dump or jmap -histo option when pid is not responding)
- J(option): Passes option to the Java virtual machine on which jmap is running.
From CLI
Usage:
jmap [option] <pid>
(to connect to running process)
jmap [option] <executable <core>
(to connect to a core file)
jmap [option] [server_id@]<remote server IP or hostname>
(to connect to remote debug server)
where <option> is one of:
<none> to print same info as Solaris pmap
-heap to print java heap summary
-histo[:live] to print histogram of java object heap; if the "live"
suboption is specified, only count live objects
-clstats to print class loader statistics
-finalizerinfo to print information on objects awaiting finalization
-dump:<dump-options> to dump java heap in hprof binary format
dump-options:
live dump only live objects; if not specified,
all objects in the heap are dumped.
format=b binary format
file=<file> dump heap to <file>
Example: jmap -dump:live,format=b,file=heap.bin <pid>
-F force. Use with -dump:<dump-options> <pid> or -histo
to force a heap dump or histogram when <pid> does not
respond. The "live" suboption is not supported
in this mode.
-h | -help to print this help message
-J<flag> to pass <flag> directly to the runtime system
Notes :
- If the given process is running on a 64-bit VM, we need to specify the -J-d64 option.
- In windows, the system path variable should contain jvm.dll(for my PC, it is in C:\Program Files\Java\jre6\bin\server).
Thanks..:)