** 命令輸入方式 :**
選擇要運行的源文件,右鍵選擇Run As -> Run Configurations -> Arguments
在 VM argument 輸入框中輸入要運行的命令
查看垃圾回收情況:
-verbose:gc //在控制檯輸出GC情況
-XX:+PrintGCDetails //在控制檯輸出詳細的GC情況
-Xloggc: filepath //將GC日誌輸出到指定文件中
輸出的日誌:
8.003: [GC (Allocation Failure) [PSYoungGen: 33280K->2696K(38400K)] 33280K->2704K(125952K), 0.0026782 secs] [Times: user=0.02 sys=0.00, real=0.02 secs]
8.661: [GC (Allocation Failure) [PSYoungGen: 35976K->4181K(38400K)] 35984K->4197K(125952K), 0.0038111 secs] [Times: user=0.03 sys=0.03, real=0.02 secs]
9.509: [GC (Allocation Failure) [PSYoungGen: 37461K->5109K(38400K)] 37477K->5557K(125952K), 0.0038902 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
分析: