1、常用JVM配置参数
- Trace跟踪参数
- 堆的分配参数
- 栈的分配参数
1.1Trace跟踪参数
打印GC信息:
-verbose:gc
-XX:+PrintGC
-XX:+PrintGCDetails
打印GC详细信息
-XX:+PrintGCTimeStamps
打印CG发生的时间戳
各个参数效果:
package com.thread.study;
public class GCPrint {
public static void main(String[] args) {
for(int i = 0;i<100000000;i++){
byte[] bytes = new byte[1024*1024];
}
}
}
栈的分配参数
-verbose:gc
[GC (Allocation Failure) 853077K->608K(987648K), 0.0004369 secs]
[GC (Allocation Failure) 813447K->608K(950272K), 0.0003791 secs]
[GC (Allocation Failure) 776007K->608K(914944K), 0.0004622 secs]
[GC (Allocation Failure) 741407K->608K(881152K), 0.0004329 secs]
[GC (Allocation Failure) 706850K->608K(848896K), 0.0003218 secs]
[GC (Allocation Failure) 675424K->608K(818176K), 0.0004226 secs]
[GC (Allocation Failure) 644232K->608K(953856K), 0.0005373 secs]
[GC (Allocation Failure) 780384K->608K(1117696K), 0.0006502 secs]
[GC (Allocation Failure) 944103K->608K(131