JDK itself comes with a lot of practical tools. The following are commonly used:
1. JPs: displays all Virtual Machine Processes
-Q: only ID numbers are listed.
-M: ID, primary class, and parameters passed to the primary class
-L: ID and full name of the main class
-V: ID, primary class, and complete VM startup parameters
2. jstat: Virtual Machine statistics monitoring
Reference: http://blog.163.com/yangshuo_qq/blog/static/2554680201272871350110/
Jstat-GC PID
The GC information is displayed, and the GC count and time are displayed.
Jstat-gc pid interval count
Every interval time, count in total, display GC information, view GC times, and time. Interval: milliseconds
[Root @ redhat4 work] # jstat-GC 6910 1000 10 queries 10 times every 1000 milliseconds
S0c s1c s0u s1u ec eu oc ou PC Pu ygc ygct FGC fgct GCT
128.0 128.0 22.6 0.0 1536.0 1248.0 3456.0 3443.0 12288.0 5963.0 28 0.128 1 0.199 0.327
S0c: the capacity (in bytes) of the first surviving vor in the young generation)
S1c: the capacity (in bytes) of the second surviving vor in the young generation)
S0u: The first surviving vor in the young generation. Currently, space (in bytes) is used)
S1u: The second surviving vor in the young generation. Currently, space (in bytes) is used)
EC: Capacity (bytes) of Eden in the young generation)
EU: the young generation of Eden (Eden) currently uses space (bytes)
OC: the size of the old generation (in bytes)
Ou: the old generation currently uses space (in bytes)
PC: perm (persistent generation) Capacity (bytes)
Pu: perm (persistent generation) Space (bytes) used currently)
Ygc: slave Application Program Number of GC times in the young generation when sampling is started
Ygct: GC time in the young generation from application startup to sampling (s)
FGC: Number of GC times of the old generation (full GC) from application startup to sampling
Fgct: the time (s) taken by the old generation (full GC) GC from application startup to sampling)
GCT: Total GC time from application startup to sampling (s)
Ngcen: size (in bytes) of the initialization (minimum) in young generation (young)
Ngcmx: Maximum capacity (bytes) of young generation)
NGC: current capacity (bytes) in young generation (young)
Size (in bytes) of the initialization (minimum) in the old generation)
Ogcmx: the maximum size (in bytes) of the old generation)
OGC: the capacity (in bytes) generated by the old generation)
Pgcen: the minimum size (in bytes) of the initialization in the perm generation)
Pgcmx: Maximum capacity (bytes) of the perm generation)
PGC: the capacity (in bytes) generated by the perm generation)
S0: Percentage of the first surviving vor in the young generation used in the current capacity
S1: Percentage of used vor In the second surviving zone of the young generation in the current capacity
E: Percentage of Eden (Eden) used in the young generation in the current capacity
O: Percentage of used by the old generation to the current capacity
P: Percentage of the used perm generation to the current capacity
S0cmx: Maximum capacity (in bytes) of the first surviving vor in the young generation)
S1cmx: Maximum capacity (in bytes) of the second surviving vor in the young generation)
Ecmx: the maximum capacity (in bytes) of Eden in the young generation)
DSS: the capacity (in bytes) of the active VOR (the Eden zone is full)
TT: the maximum number of Hold times.
MTT: Maximum number of Hold times limit
Sun official document http://download.oracle.com/javase/1.5.0/docs/tooldocs/share/jstat.html
3. jinfo: JVM configuration information
[Root @ redhat4 work] # jinfo-flag cmsinitiatingoccupancyfraction 6910
-XX: cmsinitiatingoccupancyfraction =-1
4. jmap: generate a memory Snapshot
[Root @ redhat4 work] # jmap-dump: format = B, file = tomcat. Bin 6910
Dumping heap to/work/tomcat. bin...
Heap Dump File Created
5. jhat: Snapshot memory analysis tool
[Root @ redhat4 work] # jhat tomcat. Bin
Reading from tomcat. bin...
Dump File Created Mon Apr 15 11:15:27 CST 2013
Snapshot read, resolving...
Resolving 120986 objects...
Chasing references, please CT 24 dots ........................
Eliminating duplicate references ........................
Snapshot resolved.
Started HTTP server on port 7000
Server is ready.
The server is ready. It indicates that the analysis has been completed. You can view the analysis result through http: // localhost: 7000 in the browser.
This tool is not easy to understand. The more convenient analysis tool is to use the Eclipse plug-in mat:
Choose Help-> install new software-> Update site: http://download.eclipse.org/mat/1.2/update-site/ in eclipse
Reference: http://chiyx.iteye.com/blog/1528782
6. jstack: generate a stack Snapshot
-F: when a normal input request is not responded, the output thread stack is forced.
-L: displays the lock information in addition to the stack.
-M: If a local method is called, the local method call stack is displayed.
It can be used to view dead loops, deadlocks, and so on.
You can also useCodePrint directly.
PS: these are not difficult. They are always asked during interviews. sort them out!