After understanding the garbage collection concept in JAVA, this article lists the "jstat" commands&options to monitor JAVA GC.
-gc
It shows the current size for each heap area and its current usage (Eden, survivor, old, etc.), total number of GC performed, and the accumulated time for GC operations.
[root@admin]# jps
2304 ResourceManager
[root@admin]# jstat -gc 2304 1000
S0C S1C S0U S1U EC EU OC OU PC PU YGC YGCT FGC FGCT GCT
8064.0 8064.0 0.0 388.5 65088.0 61409.2 163520.0 8074.1 31616.0 31553.6 9 0.149 0 0.000 0.149
8064.0 8064.0 0.0 388.5 65088.0 61409.3 163520.0 8074.1 31616.0 31553.6 9 0.149 0 0.000 0.149
Above commands firstly find out the vmid of "Resource Manager", and check the overall GC situation every 1000 ms(1 second).
Below are the description for each column.
Column | Description |
S0C | Current size of Survivor0 area in KB |
S1C | Current size of Survivor1 area in KB |
S0U | Used Survivor0 area in KB |
S1U | Used Survivor1 area in KB |
EC | Current size of Eden area in KB |
EU | Used Eden area in KB |
OC | Current size of old area in KB |
OU | Used old area in KB |
PC | Current size of permanent area in KB |
PU | Used permanent area in KB |
YGC | The number of GC event occurred in young area |
YGCT | The accumulated time for GC operations for Yong area |
FGC | The number of full GC event occurred |
FGCT | The accumulated time for full GC operations |
GCT | The total accumulated time for GC operations |
Above example output shows: YGC=9, YGCT=0.149(seconds), which means each GC in Young area took 0.149/9=0.0166(seconds).
-gcutil
Shows the usage for each heap area in percentage. Also shows the total number of GC performed and the accumulated time for GC operations.
[root@admin]# jstat -gcutil 2304 1000
S0 S1 E O P YGC YGCT FGC FGCT GCT
5.00 0.00 5.87 4.94 99.84 12 0.164 0 0.000 0.164
5.00 0.00 5.87 4.94 99.84 12 0.164 0 0.000 0.164
-gccause
It shows the "information provided by -gcutil" + reason for the last GC and the reason for the current GC.
[root@admin ~]# jstat -gccause 2304 1000
S0 S1 E O P YGC YGCT FGC FGCT GCT LGCC GCC
5.00 0.00 32.97 4.94 99.84 12 0.164 0 0.000 0.164 Allocation Failure No GC
5.00 0.00 33.29 4.94 99.84 12 0.164 0 0.000 0.164 Allocation Failure No GC
Column | Description |
LGCC | The cause for the last GC occurrence |
GCC | The cause for the current GC occurrence |
-gcnew
Shows the GC performance data for the new area.
[root@admin ~]# jstat -gcnew 2304 1000
S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT
8064.0 8064.0 403.4 0.0 6 6 4032.0 65088.0 30030.4 12 0.164
8064.0 8064.0 403.4 0.0 6 6 4032.0 65088.0 30030.4 12 0.164
Column | Description |
TT | Tenuring threshold. If copied this amount of times in young area (S0 ->S1, S1->S0), they are then moved to old area. |
MTT | Maximum Tenuring threshold. |
DSS | Desired survivor size in KB. |
-gcold
Shows the GC performance data for the old area.
[root@admin ~]# jstat -gcold 2304 1000
PC PU OC OU YGC FGC FGCT GCT
31616.0 31565.9 163520.0 8074.1 12 0 0.000 0.164
31616.0 31565.9 163520.0 8074.1 12 0 0.000 0.164
-gcpermcapacity
Shows statistics for the permanent area.
[root@admin ~]# jstat -gcpermcapacity 2304 1000
PGCMN PGCMX PGC PC YGC FGC FGCT GCT
21248.0 83968.0 31616.0 31616.0 12 0 0.000 0.164
21248.0 83968.0 31616.0 31616.0 12 0 0.000 0.164
Column | Description |
PGCMN | The minimum size of permanent area in KB. |
PGCMX | The maximum size of permanent area in KB. |
PGC | Current size of permanent generation area in KB. |
-printcompilation
HotSpot Compiler Method Statistics.
[root@admin ~]# jstat -printcompilation 2304 1000
Compiled Size Type Method
568 178 1 org/mortbay/jetty/HttpFields destroy
568 178 1 org/mortbay/jetty/HttpFields destroy
Column | Description |
Compiled | Number of compilation tasks performed by the most recently compiled method. |
Size | Number of bytes of bytecode of the most recently compiled method. |
Type | Compilation type of the most recently compiled method. |
Method | Class name and method name identifying the most recently compiled method. Class name uses "/" instead of "." as namespace separator. Method name is the method within the given class. The format for these two fields is consistent with the HotSpot - XX:+PrintComplation option. |
-class
Show Class Loader Statistics.This is to detect ClassLoader leaks.
[root@admin ~]# jstat -class 2304 1000
Loaded Bytes Unloaded Bytes Time
5798 11127.9 0 0.0 4.46
5798 11127.9 0 0.0 4.46
Column | Description |
Loaded | Number of classes loaded. |
Bytes | Number of Kbytes loaded. |
Unloaded | Number of classes unloaded. |
Bytes | Number of Kbytes unloaded. |
Time | Time spent performing class load and unload operations. |
No comments:
Post a Comment