java gc日志在哪

java gc日志在哪,第1张

-XX:+PrintGC 输出GC日志

-XX:+PrintGCDetails 输出GC的详细日志

-XX:+PrintGCTimeStamps 输出GC的时大敬闹间戳(以基准时间的稿粗形式)

-XX:+PrintGCDateStamps 输出GC的时间戳(以日期的形式,如 2013-05-04T21:53:59.234+0800)

-XX:+PrintHeapAtGC 在进行GC的前后打印出堆的信息

-Xloggc:../logs/gc.log 日志文滚罩件的输出路径

1. Run as ->Run configurations ->java应用名 ->arguments ->VM arguments,加入jvm参数就行

2. 测试代码

[java] view plain copy

package cn.erong.test

public class Jtest {

private static final int _1M = 1024*1024

public static void main(String[] args) {

byte[] allocation1,allocation2,allocation3,allocation4

allocation1 = new byte[_1M/4]

allocation2 = new byte[_1M/4]

allocation3 = new byte[4*_1M]

allocation4 = new byte[4*_1M]

allocation4 = null

allocation4 = new byte[4*_1M]

}

}

3.  测试看下,在vm arguments 中加入

[java] view plain copy

-Xms20m --jvm堆的最小值

-Xmx20m --jvm堆的最大值

-XX:+PrintGCTimeStamps -- 贺弊打印出GC的时间信息

-XX:+PrintGCDetails  --打印出GC的详细信息

-verbose:gc --开启gc日志

-Xloggc:d:/gc.log -- gc日志的存放位置

-Xmn10M -- 新生代内存区域的大小

-XX:SurvivorRatio=8 --新生代内禅皮族存区域中Eden和Survivor的比例

4 . run  看下日志,到d盘找到 gc.log,如下

[plain] view plain copy

Java HotSpot(TM) Client VM (25.151-b12) for windows-x86 JRE (1.8.0_151-b12), built on Sep  5 2017 19:31:49 by "java_re" with MS VC++ 10.0 (VS2010)

Memory: 4k page, physical 3567372k(982296k free), swap 7133056k(3042564k free)

CommandLine flags: -XX:InitialHeapSize=20971520 -XX:MaxHeapSize=20971520 -XX:MaxNewSize=10485760 -XX:NewSize=10485760 -XX:+PrintGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:SurvivorRatio=8 握凯-XX:-UseLargePagesIndividualAllocation

0.091: [GC (Allocation Failure) 0.091: [DefNew: 5427K->995K(9216K), 0.0036445 secs] 5427K->5091K(19456K), 0.0038098 secs] [Times: user=0.00 sys=0.02, real=0.00 secs]

0.095: [GC (Allocation Failure) 0.095: [DefNew: 5091K->0K(9216K), 0.0012412 secs] 9187K->5090K(19456K), 0.0012908 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]

Heap

def new generation   total 9216K, used 4260K [0x04000000, 0x04a00000, 0x04a00000)

eden space 8192K,  52% used [0x04000000, 0x044290e8, 0x04800000)

from space 1024K,   0% used [0x04800000, 0x04800000, 0x04900000)

to   space 1024K,   0% used [0x04900000, 0x04900000, 0x04a00000)

tenured generation   total 10240K, used 5090K [0x04a00000, 0x05400000, 0x05400000)

the space 10240K,  49% used [0x04a00000, 0x04ef8ac0, 0x04ef8c00, 0x05400000)

Metaspace       used 84K, capacity 2242K, committed 2368K, reserved 4480K

gc工作段塌团日志导入方法握橘如下:

1、双击GC的应用程序文件,打开GC软件。

2、点击窗口的最大化按扭,衫铅使编辑窗口最大化。

3、点选FILE-IMPORT(文件-导入)进入导入设置界面。

4、通过查找范围的下拉列表中找到需要打开的工作日志文件夹。

5、点击导入即可。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/tougao/12256294.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存