In-depth understanding of java virtual machine --- virtual machine tool jhat (16)

jhat

The JVM Heap Analysis Tool command is used in conjunction with jmap to analyze the dump generated by jmap. jhat has a built-in miniature HTTP/HTML server. After the analysis result of the dump is generated, it can be viewed in the browser. It should be noted here that analysis is generally not performed directly on the server, because jhat is a time-consuming and hardware resource-consuming process. Generally, the dump file generated by the server is copied to a local or other machine for analysis. 【Memory Analysis】

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[root@localhost bin] # jhat -help
Usage:  jhat [-stack <bool>] [-refs <bool>] [-port <port>] [-baseline < file >] [-debug <int>] [-version] [-h|-help] < file >
 
     -J<flag>          Pass <flag> directly to the runtime system. For
               example, -J-mx512m to use a maximum heap size of 512MB
     -stack false :     Turn off tracking object allocation call stack.
     -refs false :      Turn off tracking of references to objects
     -port <port>:     Set the port for  the HTTP server.  Defaults to 7000
     -exclude < file >:  Specify a file  that lists data members that should
               be excluded from the reachableFrom query.
     -baseline < file >: Specify a baseline object dump.  Objects in
               both heap dumps with the same ID and same class will
               be marked as not being "new" .
     -debug <int>:     Set debug level.
                 0:  No debug output
                 1:  Debug hprof file  parsing
                 2:  Debug hprof file  parsing, no server
     -version          Report version number
     -h|-help          Print this help and exit
     < file >            The file  to read
 
For a dump file  that contains multiple heap dumps,
you may specify which  dump in  the file
by appending "#<number>"  to the file  name, i.e. "foo.hprof#3" .
 
All boolean options default to "true"

 

parameter

-J< flag >                 
Because the jhat command actually starts a JVM for execution, you can pass in some startup parameters when starting the JVM with -J. For example, -J-Xmx512m specifies that the maximum heap memory used by the Java virtual machine running jhat is 512 MB. If If you need to use multiple JVM startup parameters, pass in multiple -Jxxxxxx.
-stack false|true 
Turn off tracking object allocation call stack. If allocation location information is not available in the heap dump. This flag must be set to false. Default is true.
-refs false|true 
Turn off tracking of references to objects. The default value is true. By default, the returned pointers are objects that point to other specific objects, such as backlinks or incoming references (referrers or incoming references), which count/count all objects in the heap.
-port port-number 
Set the port number of the jhat HTTP server. The default value is 7000.
-exclude exclude-file 
Specifies a file that lists data members that should be excluded from the reachable objects query. For example, if the file column lists java.lang.String.value, then when calculating the list of reachable objects from a particular object Object o, references to paths involving java.lang.String.value are excluded.
-baseline exclude-file 
Specifies a baseline heap dump. Objects with the same object ID in two heap dumps are marked as not being new. Other objects are marked as new. Useful when comparing two different heap dumps .
-debug int 
Set the debug level. 0 means no debug information is output. The larger the value, the more detailed debug information will be output.
-version 
After startup, only the version information is displayed and then it exits.

Example
1
jhat -J-Xmx512m dump.hprof
1
jhat -port 7000 mem.dat
  • jmap -dump:format=b,file=mem.dat pid #Output the details of memory usage to the mem.dat file
    Through jhat -port 7000 mem.dat, the content of mem.dat can be exposed to the network in the form of web, Visit http://ip-server:7000 to view.

 Generally, the heap exceptions are mainly viewed in these two parts: Show instance counts for all classes (excluding platform), all object information outside the platform. Show heap histogram displays the heap in a tree diagram.

 
 
 Observe if a large number of objects that should be reclaimed are being referenced all the time or if there are objects that take up too much memory and cannot be reclaimed.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325400603&siteId=291194637