Jmap
Print out a JavaProcess (UsePID) In memory, all'Object'(For example, the generated objects and their quantity ).
Tools that can output all objects in the memory, or even VMInHeapIn binary format. UsageJmap-histo PID. If used togetherShell jmap-histo pid> A. LogYou can save it to text. After a period of time, you can use the text comparison tool to compareGCWhich objects are recycled.Jmap-dump: format = B, file = OUTFILE 3024You can set3024Process MemoryHeapOutputIn the OUTFILE file, use the mat (memory analysis tool ).(Memory analysis tool) OrJhat (Java heap analysis tool)In combination, the current memory is displayed visually in the form of images.
Use the following method on a 64-bit machine:
Jmap J-d64-heap PID
Command Format
Jmap [Option] PID
Jmap [Option] executable Core
Jmap [Option] [server-ID @] Remote-hostname-or-IP
Parameter description
1 ),OPtions:
Executable Java executable from which the core dump was produced.
(It may beCore DumpOfJavaExecutableProgram)
CoreTheCore DumpFile
Remote-hostname-or-IPRemoteDebugService host name orIP
Server-IDUniqueID,Assume that multiple remoteDebugService
2)And basic parameters:
-Dump: [live,] format = B, file = <FILENAME> UseHprofBinary format,OutputJVMOfHeapContent to file=. LiveSub-options are optional.LiveOption,Then, only the live objects are output to the file..
-Finalizerinfo: prints the information of the object waiting for recycling..
-Heap PrintingHeap,GCUsedAlgorithm,HeapConfiguration andWise heapUsage.
-Histo [: Live]: print eachClassNumber of instances,Memory usage,Class full name information. VMThe prefix"*".IfLiveAfter the sub-parameter is added,Only count the number of active objects.
-Permstat PrintingClassloadAndJVM heapPersistent layer information.Contains eachClassloaderName,Dynamic,Address,ParentClassloaderAnd loadClassQuantity.In addition,InternalStringThe number and memory usage will also be printed..
-F force.InPIDWhen no response is available-DumpOr-HistoParameters.In this mode, LiveInvalid sub-Parameter.
-H |-help: print the auxiliary information
-J: Pass the parameterJmapStartedJVM.
PID needs to be printed with the matching informationJavaProcessID
Example
Query the summary of the JVM heap
Blue @ blue-PC :~ /Apache-Tomcat- 7.0 . 39 /Conf $ JPs- ML 2491 9142 Org. Apache. Catalina. startup. Bootstrap start 9168 Sun. Tools. JPs. JPs- ML 2967
Root @ blue -PC:/home/blue/Apache-Tomcat- 7.0 . 39 /Conf # jmap-heap 9142 Attaching to process ID 9142 , Please Wait ... Debugger Attached successfully. Server compiler detected. JVM version is 20.10 - B01using thread -Local Object Allocation. Parallel GC 4 Thread (s) Heap configuration: minheapfreeratio = 40 Maxheapfreeratio = 70 Maxheapsize = 1031798784 ( 984 . 0 MB) newsize = 1048576 ( 1 . 0 MB) maxnewsize =4294901760 ( 4095 . 9375 MB) oldsize = 4194304 ( 4 . 0 MB) newratio = 2 Survivorratio = 8 Permsize = 16777216 ( 16 . 0 MB) maxpermsize =67108864 ( 64 . 0 MB) Heap usage: PS young generationeden space: Capacity = 16121856 ( 15 . 375 MB) used = 15074368 ( 14 . 37603759765625 MB) Free = 1047488 ( 0 . 99896240234375 MB) 93.50268356199187 % Usedfrom space: Capacity = 2686976 ( 2 . 5625 MB) used = 2684584 ( 2 . 5602188110351562 MB) Free = 2392 ( 0 . 00228118896484375 MB) 99.91097799161585 %Usedto space: Capacity = 2686976 ( 2 . 5625 MB) used = 0 ( 0 . 0 MB) Free = 2686976 ( 2 . 5625 MB) 0.0 % Usedps old generation capacity = 42991616 ( 41 . 0 MB) used = 5071824 ( 4 . 8368682861328125 MB) Free = 37919792 ( 36 . 16313171386719 MB) 11.797239722275153 % Usedps perm generation capacity = 16777216 ( 16 . 0 MB) used = 11304456 ( 10 . 780769348144531 MB) Free = 5472760 ( 5 . 219230651855469 MB) 67.37980842590332 % Used
Dump JVM memory information
Root @ blue-PC:/home/blue/Apache-Tomcat-7.0.39/Conf # jmap-F-dump: format = B,File= Tomcat. Bin9142Attaching to process ID9142, PleaseWait... Debugger Attached successfully. Server compiler detected. JVM version is20.10-B01dumping heap to Tomcat. Bin... findingObjectSize Using printezis bits and skipping over... heap dumpFileCreated
Jhat
Purpose: it is a command used to analyze the Java heap. It can display objects in the heap in HTML format, including the number and size of objects, and supports the object query language.
Use jhat to view the tomcat. Bin dump file
Root @ blue-PC:/home/blue/Apache-Tomcat-7.0.39/Conf # jhat tomcat. Bin... started HTTP server on port7000Server is ready.
Access http: // localhost: 7000 to view detailed memory information.
Sometimes the heap you dump out is very large, and an error of insufficient heap space will be reported at startup. You can use the following parameters:
Jhat J-Xmx512m File>
More references http://blog.csdn.net/gtuu0123/article/details/6039474