- Trace跟踪参数
- 堆的分配参数
- 栈的分配参数
Trace跟踪参数
-
-verbose:gc
-
-XX:+printGC
-
可以打印GC的简要信息
- [GC 4790K->374K(15872K), 0.0001606 secs]
- [GC 4790K->374K(15872K), 0.0001474 secs]
- [GC 4790K->374K(15872K), 0.0001563 secs]
- [GC 4790K->374K(15872K), 0.0001682 secs]
-
-XX:+PrintGCDetails
- 打印GC详细信息
-
-XX:+PrintGCTimeStamps
- 打印CG发生的时间戳
例
- 打印CG发生的时间戳
[GC[DefNew: 4416K->0K(4928K), 0.0001897 secs] 4790K->374K(15872K), 0.0002232 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
-
-Xloggc:log/gc.log
- 指定GC log的位置,以文件输出
- 帮助开发人员分析问题
-
-XX:+PrintHeapAtGC
- 每次一次GC后,都打印堆信息
{Heap before GC invocations=0 (full 0):
def new generation total 3072K, used 2752K [0x33c80000, 0x33fd0000, 0x33fd0000)
eden space 2752K, 100% used [0x33c80000, 0x33f30000, 0x33f30000)
from space 320K, 0% used [0x33f30000, 0x33f30000, 0x33f80000)
to space 320K, 0% used [0x33f80000, 0x33f80000, 0x33fd0000)
tenured generation total 6848K, used 0K [0x33fd0000, 0x34680000, 0x34680000)
the space 6848K, 0% used [0x33fd0000, 0x33fd0000, 0x33fd0200, 0x34680000)
compacting perm gen total 12288K, used 143K [0x34680000, 0x35280000, 0x38680000)
the space 12288K, 1% used [0x34680000, 0x346a3c58, 0x346a3e00, 0x35280000)
ro space 10240K, 44% used [0x38680000, 0x38af73f0, 0x38af7400, 0x39080000)
rw space 12288K, 52% used [0x39080000, 0x396cdd28, 0x396cde00, 0x39c80000)
[GC[DefNew: 2752K->320K(3072K), 0.0014296 secs] 2752K->377K(9920K), 0.0014604 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
Heap after GC invocations=1 (full 0):
def new generation total 3072K, used 320K [0x33c80000, 0x33fd0000, 0x33fd0000)
eden space 2752K, 0% used [0x33c80000, 0x33c80000, 0x33f30000)
from space 320K, 100% used [0x33f80000, 0x33fd0000, 0x33fd0000)
to space 320K, 0% used [0x33f30000, 0x33f30000, 0x33f80000)
tenured generation total 6848K, used 57K [0x33fd0000, 0x34680000, 0x34680000)
the space 6848K, 0% used [0x33fd0000, 0x33fde458, 0x33fde600, 0x34680000)
compacting perm gen total 12288K, used 143K [0x34680000, 0x35280000, 0x38680000)
the space 12288K, 1% used [0x34680000, 0x346a3c58, 0x346a3e00, 0x35280000)
ro space 10240K, 44% used [0x38680000, 0x38af73f0, 0x38af7400, 0x39080000)
rw space 12288K, 52% used [0x39080000, 0x396cdd28, 0x396cde00, 0x39c80000)
}
- -XX:+TraceClassLoading
- 监控类的加载
- [Loaded java.lang.Object from shared objects file]
- [Loaded java.io.Serializable from shared objects file]
- [Loaded java.lang.Comparable from shared objects file]
- [Loaded java.lang.CharSequence from shared objects file]
- [Loaded java.lang.String from shared objects file]
- [Loaded java.lang.reflect.GenericDeclaration from shared objects file]
- [Loaded java.lang.reflect.Type from shared objects file]
- 监控类的加载
- -XX:+PrintClassHistogram
- 按下Ctrl+Break后,打印类的信息:
num #instances #bytes class name
----------------------------------------------
1: 890617 470266000 [B
2: 890643 21375432 java.util.HashMap$Node
3: 890608 14249728 java.lang.Long
4: 13 8389712 [Ljava.util.HashMap$Node;
5: 2062 371680 [C
6: 463 41904 java.lang.Class
- 分别显示:序号、实例数量、总大小、类型