functionThe Jmap (Memory Map for Java) command is used to generate a heap dump snapshot (commonly known as a heaphump or dump file). If you do not use the Jmap command, there are some more "brute force" means to get a Java heap dump snapshot: Using the-xx:heapdumponoutofmemoryerror parameter, you can have the VM automatically generate a dump file after the Oom exception occurs, via-XX: The Heapdumponctrlbreak parameter allows the virtual machine to generate a dump file using the [Ctrl]+[break] key, or the dump file can be "intimidated" by the Kill-3 command sending process exit signal under the Linux system. Jmap's role is not just to get the dump file, it can also query the details of the Finalize execution queue, the Java heap, and the permanent generation, such as the space usage, which collector is currently used, and so on.
Commandjmap [option] Vmid
Description-dump: Generates a Java heap dump snapshot. The format is:-dump:[live,]format=b,file=<filename>, where the live sub-argument indicates whether to dump only the surviving object. -finalizerinfo: Displays the object in F-queue that waits for the finalizer thread to execute the Finalize method. Valid only under the Linux/solaris platform. -heap: Displays Java heap details, such as which collector to use, parameter configuration, generational status, and so on. Valid only under the Linux/solaris platform. -histo: Displays the object statistics in the heap, including the class, number of instances, and total capacity. -permstat: Displays the permanent memory status with ClassLoader as the statistical aperture. Valid only under the Linux/solaris platform. -F: Use this option to force a dump snapshot when the virtual machine process does not respond to the-dump option. Valid only under the Linux/solaris platform.
ExampleJmap-dump:format=b,file=eclipse.bin 3500
Jmap (Memory Map for Java)