Jmap (Memory Map for Java)
The Jmap command is used to generate a heap dump snapshot (commonly referred to as a heapdump or dump file)
If you do not use the Jmap command, to get a Java heap dump snapshot, there are some more violent means: for example, using a JVM parameter,-xx:+heapdumponoutofmemoryerror, allows the virtual machine to automatically generate dump files when an oom exception occurs. With the-xx:heapdumponctrlbreak parameter, you can use the [Ctrl]+[break] key to have the virtual machine generate a dump file, or, under a Linux system, send a process exit signal with the Kill-3 command to "scare" the virtual machine, can also get the dump file.
Parameters I've tried to be no problem linux command I didn't try
Jmap's role is not only to get the dump file, he can also query the Finalize execution queue ,Java heap and the details of the permanent generation , such as the space usage, the current type of collector and so on.
As with the Jinfo command, Jmap has a number of features that are limited under the Windows platform, in addition to the-dump options for generating dump files and the-histo options for viewing instances of each class, the Space occupancy statistics
Outside of all operating systems, the remaining options are available only on the Linux/solaris platform (this is not to promote Linux 0.0)
Well, come down and learn the orders, and execute
jmap [option] Vmid
Although there are restrictions on the function of the commands, let's just list them.
-dump generates a Java heap dump snapshot in the form of:-dump:[live,]format=b, File=<filename>, where live self-parameter description only dump out the surviving object
-finalizerinfo show objects in F-queue waiting for finalizer thread to execute finalizer method
-HEAP Displays Java heap details, such as using that collector, parameter configuration, generational status
-histo Display statistics for objects in the heap, including classes, number of instances, total capacity
-permstat Display permanent memory status with ClassLoader as statistical aperture
-F when the virtual machine process does not respond to the-dump option, you can use this option to force the dump snapshot to be generated
Here is an example, a picture
Let's get a dump file generated.
Jmap-dump:format-b,file=eclipse.bin 6832
You can see that the file is created and the directory that you created is the current directory where PWD resides
So the rest of the problem is how to analyze the dump file!!!
Jmap:java Memory Image tool