GC 日志相关选项

一 常用选项

-XX:+PrintGC <==> -verbose:gc  打印简要日志信息,独立使用

-XX:+PrintGCDetails            打印详细日志信息,独立使用

-XX:+PrintGCTimeStamps  打印程序启动到GC发生的时间,搭配 -XX:+PrintGCDetails 使用,不可以独立使用

-XX:+PrintGCDateStamps  打印GC发生时的时间戳,搭配 -XX:+PrintGCDetails 使用,不可以独立使用

-XX:+PrintHeapAtGC  打印 GC 前后的堆信息,独立使用

-Xloggc:<file> 输出 GC 到指定路径下的文件中

二 其他选项

-XX:+TraceClassLoading  监控类的加载

-XX:+PrintGCApplicationStoppedTime  打印 GC 时线程的停顿时间

-XX:+PrintGCApplicationConcurrentTime  打印垃圾收集之前应用未中断的执行时间

-XX:+PrintReferenceGC 打印回收了多少种不同引用类型的引用

-XX:+PrintTenuringDistribution  打印 JVM 在每次 MinorGC 后当前使用的 Survivor 中对象的年龄分布

-XX:+UseGCLogFileRotation 启用 GC 日志文件的自动转储

-XX:NumberOfGCLogFiles=1  设置 GC 日志文件的循环数目

-XX:GCLogFileSize=1M  设置 GC 日志文件的大小

三 实战

1 代码

package chapter04;

import java.util.ArrayList;
/**
* -Xms60m -Xmx60m -XX:SurvivorRatio=8 -verbose:gc
* -Xms60m -Xmx60m -XX:SurvivorRatio=8 -XX:+PrintGC
* -Xms60m -Xmx60m -XX:SurvivorRatio=8 -XX:+PrintGCDetails
* -Xms60m -Xmx60m -XX:SurvivorRatio=8 -XX:+PrintGCDetails -XX:+PrintGCTimeStamps
* -Xms60m -Xmx60m -XX:SurvivorRatio=8 -XX:+PrintGCDetails -XX:+PrintGCDateStamps
* -Xms60m -Xmx60m -XX:SurvivorRatio=8 -XX:+PrintHeapAtGC
* -Xms60m -Xmx60m -XX:SurvivorRatio=8 -XX:+PrintHeapAtGC -XX:+PrintGCDetails -Xloggc:d:/heaplog.log
* -Xms60m -Xmx60m -XX:SurvivorRatio=8 -XX:+PrintGCApplicationStoppedTime
*/
public class GCLogTest {
    public static void main(String[] args) {
        ArrayList<byte[]> list = new ArrayList<>();


        for (int i = 0; i < 500; i++) {
            byte[] arr = new byte[1024 * 100];// 100kb
            list.add(arr);
            try {
                Thread.sleep(20);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

2 设置为 -Xms60m -Xmx60m -XX:SurvivorRatio=8 -verbose:gc 启动

[GC (Allocation Failure)  16294K->14546K(59392K), 0.0039367 secs]

[GC (Allocation Failure)  30894K->30517K(59392K), 0.0055465 secs]

[Full GC (Ergonomics)  30517K->30300K(59392K), 0.0108135 secs]

[Full GC (Ergonomics)  46584K->46402K(59392K), 0.0069119 secs]

3 设置为 -Xms60m -Xmx60m -XX:SurvivorRatio=8 -XX:+PrintGC

[GC (Allocation Failure)  16384K->14378K(59392K), 0.0042745 secs]

[GC (Allocation Failure)  30698K->30688K(59392K), 0.0048966 secs]

[Full GC (Ergonomics)  30688K->30561K(59392K), 0.0122676 secs]

[Full GC (Ergonomics)  46905K->46564K(59392K), 0.0098682 secs]

4 设置为 -Xms60m -Xmx60m -XX:SurvivorRatio=8 -XX:+PrintGCDetails

[GC (Allocation Failure) [PSYoungGen: 16384K->2036K(18432K)] 16384K->14422K(59392K), 0.0043724 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]

[GC (Allocation Failure) [PSYoungGen: 18356K->2020K(18432K)] 30742K->30672K(59392K), 0.0046265 secs] [Times: user=0.02 sys=0.08, real=0.00 secs]

[Full GC (Ergonomics) [PSYoungGen: 2020K->0K(18432K)] [ParOldGen: 28652K->30561K(40960K)] 30672K->30561K(59392K), [Metaspace: 3726K->3726K(1056768K)], 0.0156724 secs] [Times: user=0.00 sys=0.00, real=0.02 secs]

[Full GC (Ergonomics) [PSYoungGen: 16343K->6100K(18432K)] [ParOldGen: 30561K->40463K(40960K)] 46905K->46564K(59392K), [Metaspace: 3727K->3727K(1056768K)], 0.0097613 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]

Heap

PSYoungGen      total 18432K, used 10679K [0x00000000fec00000, 0x0000000100000000, 0x0000000100000000)

  eden space 16384K, 65% used [0x00000000fec00000,0x00000000ff66dc00,0x00000000ffc00000)

  from space 2048K, 0% used [0x00000000ffe00000,0x00000000ffe00000,0x0000000100000000)

  to   space 2048K, 0% used [0x00000000ffc00000,0x00000000ffc00000,0x00000000ffe00000)

ParOldGen       total 40960K, used 40463K [0x00000000fc400000, 0x00000000fec00000, 0x00000000fec00000)

  object space 40960K, 98% used [0x00000000fc400000,0x00000000feb83e40,0x00000000fec00000)

Metaspace       used 3733K, capacity 4536K, committed 4864K, reserved 1056768K

  class space    used 408K, capacity 428K, committed 512K, reserved 1048576K

5 设置为 -Xms60m -Xmx60m -XX:SurvivorRatio=8 -XX:+PrintGCDetails -XX:+PrintGCTimeStamps

4.396: [GC (Allocation Failure) [PSYoungGen: 16384K->2036K(18432K)] 16384K->14406K(59392K), 0.0047065 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]

9.561: [GC (Allocation Failure) [PSYoungGen: 18357K->1960K(18432K)] 30726K->30740K(59392K), 0.0063010 secs] [Times: user=0.00 sys=0.01, real=0.01 secs]

9.567: [Full GC (Ergonomics) [PSYoungGen: 1960K->0K(18432K)] [ParOldGen: 28780K->30561K(40960K)] 30740K->30561K(59392K), [Metaspace: 3726K->3726K(1056768K)], 0.0168554 secs] [Times: user=0.06 sys=0.00, real=0.02 secs]

14.630: [Full GC (Ergonomics) [PSYoungGen: 16343K->6100K(18432K)] [ParOldGen: 30561K->40463K(40960K)] 46905K->46564K(59392K), [Metaspace: 3726K->3726K(1056768K)], 0.0055275 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]

Heap

PSYoungGen      total 18432K, used 10679K [0x00000000fec00000, 0x0000000100000000, 0x0000000100000000)

  eden space 16384K, 65% used [0x00000000fec00000,0x00000000ff66dc00,0x00000000ffc00000)

  from space 2048K, 0% used [0x00000000ffe00000,0x00000000ffe00000,0x0000000100000000)

  to   space 2048K, 0% used [0x00000000ffc00000,0x00000000ffc00000,0x00000000ffe00000)

ParOldGen       total 40960K, used 40463K [0x00000000fc400000, 0x00000000fec00000, 0x00000000fec00000)

  object space 40960K, 98% used [0x00000000fc400000,0x00000000feb83f18,0x00000000fec00000)

Metaspace       used 3732K, capacity 4536K, committed 4864K, reserved 1056768K

  class space    used 408K, capacity 428K, committed 512K, reserved 1048576K

6 设置为 -Xms60m -Xmx60m -XX:SurvivorRatio=8 -XX:+PrintGCDetails -XX:+PrintGCDateStamps  

2021-09-06T08:44:49.453+0800: [GC (Allocation Failure) [PSYoungGen: 16384K->2020K(18432K)] 16384K->14426K(59392K), 0.0060231 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]

2021-09-06T08:44:54.610+0800: [GC (Allocation Failure) [PSYoungGen: 18341K->1996K(18432K)] 30746K->30712K(59392K), 0.0068602 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]

2021-09-06T08:44:54.617+0800: [Full GC (Ergonomics) [PSYoungGen: 1996K->0K(18432K)] [ParOldGen: 28716K->30565K(40960K)] 30712K->30565K(59392K), [Metaspace: 3725K->3725K(1056768K)], 0.0156272 secs] [Times: user=0.02 sys=0.00, real=0.01 secs]

2021-09-06T08:44:59.793+0800: [Full GC (Ergonomics) [PSYoungGen: 16315K->6000K(18432K)] [ParOldGen: 30565K->40864K(40960K)] 46881K->46864K(59392K), [Metaspace: 3726K->3726K(1056768K)], 0.0149928 secs] [Times: user=0.06 sys=0.02, real=0.02 secs]

Heap

PSYoungGen      total 18432K, used 10608K [0x00000000fec00000, 0x0000000100000000, 0x0000000100000000)

  eden space 16384K, 64% used [0x00000000fec00000,0x00000000ff65c3c0,0x00000000ffc00000)

  from space 2048K, 0% used [0x00000000ffe00000,0x00000000ffe00000,0x0000000100000000)

  to   space 2048K, 0% used [0x00000000ffc00000,0x00000000ffc00000,0x00000000ffe00000)

ParOldGen       total 40960K, used 40864K [0x00000000fc400000, 0x00000000fec00000, 0x00000000fec00000)

  object space 40960K, 99% used [0x00000000fc400000,0x00000000febe8030,0x00000000fec00000)

Metaspace       used 3732K, capacity 4536K, committed 4864K, reserved 1056768K

  class space    used 408K, capacity 428K, committed 512K, reserved 1048576K

7 设置为 -Xms60m -Xmx60m -XX:SurvivorRatio=8 -XX:+PrintHeapAtGC

# (full 0) 表示非 Full GC

{Heap before GC invocations=1 (full 0):

PSYoungGen      total 18432K, used 16384K [0x00000000fec00000, 0x0000000100000000, 0x0000000100000000)

  eden space 16384K, 100% used [0x00000000fec00000,0x00000000ffc00000,0x00000000ffc00000)

  from space 2048K, 0% used [0x00000000ffe00000,0x00000000ffe00000,0x0000000100000000)

  to   space 2048K, 0% used [0x00000000ffc00000,0x00000000ffc00000,0x00000000ffe00000)

ParOldGen       total 40960K, used 0K [0x00000000fc400000, 0x00000000fec00000, 0x00000000fec00000)

  object space 40960K, 0% used [0x00000000fc400000,0x00000000fc400000,0x00000000fec00000)

Metaspace       used 3725K, capacity 4536K, committed 4864K, reserved 1056768K

  class space    used 407K, capacity 428K, committed 512K, reserved 1048576K

Heap after GC invocations=1 (full 0):

PSYoungGen      total 18432K, used 2020K [0x00000000fec00000, 0x0000000100000000, 0x0000000100000000)

  eden space 16384K, 0% used [0x00000000fec00000,0x00000000fec00000,0x00000000ffc00000)

  from space 2048K, 98% used [0x00000000ffc00000,0x00000000ffdf9110,0x00000000ffe00000)

  to   space 2048K, 0% used [0x00000000ffe00000,0x00000000ffe00000,0x0000000100000000)

ParOldGen       total 40960K, used 12401K [0x00000000fc400000, 0x00000000fec00000, 0x00000000fec00000)

  object space 40960K, 30% used [0x00000000fc400000,0x00000000fd01c760,0x00000000fec00000)

Metaspace       used 3725K, capacity 4536K, committed 4864K, reserved 1056768K

  class space    used 407K, capacity 428K, committed 512K, reserved 1048576K

}

# (full 0) 表示非 Full GC

{Heap before GC invocations=2 (full 0):

PSYoungGen      total 18432K, used 18341K [0x00000000fec00000, 0x0000000100000000, 0x0000000100000000)

  eden space 16384K, 99% used [0x00000000fec00000,0x00000000ffbf0310,0x00000000ffc00000)

  from space 2048K, 98% used [0x00000000ffc00000,0x00000000ffdf9110,0x00000000ffe00000)

  to   space 2048K, 0% used [0x00000000ffe00000,0x00000000ffe00000,0x0000000100000000)

ParOldGen       total 40960K, used 12401K [0x00000000fc400000, 0x00000000fec00000, 0x00000000fec00000)

  object space 40960K, 30% used [0x00000000fc400000,0x00000000fd01c760,0x00000000fec00000)

Metaspace       used 3726K, capacity 4536K, committed 4864K, reserved 1056768K

  class space    used 407K, capacity 428K, committed 512K, reserved 1048576K

Heap after GC invocations=2 (full 0):

PSYoungGen      total 18432K, used 2020K [0x00000000fec00000, 0x0000000100000000, 0x0000000100000000)

  eden space 16384K, 0% used [0x00000000fec00000,0x00000000fec00000,0x00000000ffc00000)

  from space 2048K, 98% used [0x00000000ffe00000,0x00000000ffff9110,0x0000000100000000)

  to   space 2048K, 0% used [0x00000000ffc00000,0x00000000ffc00000,0x00000000ffe00000)

ParOldGen       total 40960K, used 28712K [0x00000000fc400000, 0x00000000fec00000, 0x00000000fec00000)

  object space 40960K, 70% used [0x00000000fc400000,0x00000000fe00a190,0x00000000fec00000)

Metaspace       used 3726K, capacity 4536K, committed 4864K, reserved 1056768K

  class space    used 407K, capacity 428K, committed 512K, reserved 1048576K

}

# (full 1) 表示第一次 Full GC

{Heap before GC invocations=3 (full 1):

PSYoungGen      total 18432K, used 2020K [0x00000000fec00000, 0x0000000100000000, 0x0000000100000000)

  eden space 16384K, 0% used [0x00000000fec00000,0x00000000fec00000,0x00000000ffc00000)

  from space 2048K, 98% used [0x00000000ffe00000,0x00000000ffff9110,0x0000000100000000)

  to   space 2048K, 0% used [0x00000000ffc00000,0x00000000ffc00000,0x00000000ffe00000)

ParOldGen       total 40960K, used 28712K [0x00000000fc400000, 0x00000000fec00000, 0x00000000fec00000)

  object space 40960K, 70% used [0x00000000fc400000,0x00000000fe00a190,0x00000000fec00000)

Metaspace       used 3726K, capacity 4536K, committed 4864K, reserved 1056768K

  class space    used 407K, capacity 428K, committed 512K, reserved 1048576K

Heap after GC invocations=3 (full 1):

PSYoungGen      total 18432K, used 0K [0x00000000fec00000, 0x0000000100000000, 0x0000000100000000)

  eden space 16384K, 0% used [0x00000000fec00000,0x00000000fec00000,0x00000000ffc00000)

  from space 2048K, 0% used [0x00000000ffe00000,0x00000000ffe00000,0x0000000100000000)

  to   space 2048K, 0% used [0x00000000ffc00000,0x00000000ffc00000,0x00000000ffe00000)

ParOldGen       total 40960K, used 30562K [0x00000000fc400000, 0x00000000fec00000, 0x00000000fec00000)

  object space 40960K, 74% used [0x00000000fc400000,0x00000000fe1d8918,0x00000000fec00000)

Metaspace       used 3726K, capacity 4536K, committed 4864K, reserved 1056768K

  class space    used 407K, capacity 428K, committed 512K, reserved 1048576K

}

# (full 2) 表示第二次 Full GC

{Heap before GC invocations=4 (full 2):

PSYoungGen      total 18432K, used 16315K [0x00000000fec00000, 0x0000000100000000, 0x0000000100000000)

  eden space 16384K, 99% used [0x00000000fec00000,0x00000000ffbeefa0,0x00000000ffc00000)

  from space 2048K, 0% used [0x00000000ffe00000,0x00000000ffe00000,0x0000000100000000)

  to   space 2048K, 0% used [0x00000000ffc00000,0x00000000ffc00000,0x00000000ffe00000)

ParOldGen       total 40960K, used 30562K [0x00000000fc400000, 0x00000000fec00000, 0x00000000fec00000)

  object space 40960K, 74% used [0x00000000fc400000,0x00000000fe1d8918,0x00000000fec00000)

Metaspace       used 3726K, capacity 4536K, committed 4864K, reserved 1056768K

  class space    used 407K, capacity 428K, committed 512K, reserved 1048576K

Heap after GC invocations=4 (full 2):

PSYoungGen      total 18432K, used 6000K [0x00000000fec00000, 0x0000000100000000, 0x0000000100000000)

  eden space 16384K, 36% used [0x00000000fec00000,0x00000000ff1dc3c0,0x00000000ffc00000)

  from space 2048K, 0% used [0x00000000ffe00000,0x00000000ffe00000,0x0000000100000000)

  to   space 2048K, 0% used [0x00000000ffc00000,0x00000000ffc00000,0x00000000ffe00000)

ParOldGen       total 40960K, used 40863K [0x00000000fc400000, 0x00000000fec00000, 0x00000000fec00000)

  object space 40960K, 99% used [0x00000000fc400000,0x00000000febe7f58,0x00000000fec00000)

Metaspace       used 3726K, capacity 4536K, committed 4864K, reserved 1056768K

  class space    used 407K, capacity 428K, committed 512K, reserved 1048576K

}

8 设置为 -Xms60m -Xmx60m -XX:SurvivorRatio=8 -XX:+PrintHeapAtGC -XX:+PrintGCDetails -Xloggc:d:/heaplog.log

9 设置为 -Xms60m -Xmx60m -XX:SurvivorRatio=8 -XX:+PrintGCApplicationStoppedTime

Total time for which application threads were stopped: 0.0001415 seconds, Stopping threads took: 0.0000461 seconds

Total time for which application threads were stopped: 0.0000912 seconds, Stopping threads took: 0.0000316 seconds

Total time for which application threads were stopped: 0.0054704 seconds, Stopping threads took: 0.0000278 seconds

Total time for which application threads were stopped: 0.0208119 seconds, Stopping threads took: 0.0000492 seconds

Total time for which application threads were stopped: 0.0058309 seconds, Stopping threads took: 0.0000393 seconds

 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
一些小事让生活变得轻松(在www.geocaching.com上)。 您可以自行选择要使用的功能。 所有功能均可通过易于使用的菜单进行配置。 全局为导航创建您自己的链接列表,就像原始导航一样,或作为其他下拉列表,从导航中删除原始gc.com链接。配置顺序,名称,...的链接,从列表中选择所有有意义的链接gc.com上的链接以及其他外部链接也有一些具有特殊功能的链接:Nearest-List,Nearest-Map,Nestest-List(无发现),用户搜索为弹出窗口创建自己的自定义链接导航中的搜索字段更改整个gc的宽度.com页面隐藏反馈按钮隐藏广告说明链接隐藏社交链接隐藏多余的换行符从google地图添加链接到geocaching.com配置页面以(取消激活)并配置所有功能配置中每个选项的小提示页(和指向德语帮助的链接)新版本的更新建议最近列表自动从最近列表重定向到地图记录最近链接中的It-Link书签最近列表中的It-Link更改找到的Cach的背景 变成绿色而不是灰色配置文件在侧边栏中的自己的链接列表在侧边栏中的可折叠框中编辑链接在自己的缓存旁边的画廊链接在自己的缓存旁边显示在公共配置文件中显示不同数量的硬币在缓存矩阵中显示“ n / 81”(统计页面) )在个人资料中建立电子邮件地址的链接在摘要页面中隐藏TB /硬币日志地图上的地图链接列表(选择要在地图上显示的链接)在地图上显示本地区域默认情况下隐藏找到/隐藏的缓存-缓存的默认设置-类型过滤器默认情况下隐藏边栏添加google和其他OSM地图选项以选择自定义默认地图山影和公共交通叠加层选项以隐藏未使用的地图图层选项以隐藏标题清单自动显示定义数量的日志“显示所有日志”-链接隐藏用户名旁边的头像邮件链接(高速缓存和TB列表)-还添加高速缓存/ TB名称,GCcode和所有者发送到邮件中隐藏空的高速缓存注释(通过链接显示)完全隐藏高速缓存注释显示高速缓存注释中的中断隐藏免责声明隐藏剧透战争 宁隐藏链接后的提示自动解密提示链接到Google地图直接在列表中记录日志缓存在TB列表gc.com中显示硬币系列的名称n修正了:解密提示中的换行符在列表中及之后在Dec和DMS中显示坐标打印页面显示“映射此位置”-链接已归档/禁用缓存的删除线标题显示列表VIP中的收藏点的百分比VIP-列表(您定义VIP,GClh在列表中显示一个列表,其中哪个VIP已找到缓存)显示在VIP上登录鼠标备用VIP样式:每个日志一个条目尚未找到缓存的VIP的可选列表“顶部”-日志中的链接突出显示列表和日志中的“相关网站”缩略图以及mouseover上的大图像(包括。 关键字过滤器,以防止显示破坏代码)按类型过滤显示的日志日志中搜索更大的图像库中的图像将标题颜色更改为红色(如果已存档缓存)在事件缓存中显示星期几高亮显示已更改的坐标BBCode(用于创建列表)菜单隐藏绿色“至顶部”按钮-显示真实所有者而不是自由文本-改进了事件的google-calendar链接,从打印页中删除了页脚从缓存和TB的日志记录默认日志类型缓存和TB日志签名的使用#found_no#表示在日志/ TB签名和模板中找到的缓存数量,#found#表示在日志/ TB签名和模板+1中找到的缓存数量。#me#表示您在日志中的用户名/ TB-Signature和Templates直接在列表中记录缓存快捷方式:F2提交日志,PQ设置,书签表情符号和BBCode在日志字段旁边用户定义的Log-Templates将Tracking-Nummer传输到TB-Log-Field设置光标为对数字段中的第一个字符-您可以开始输入immedi TB / Coins的AutoVisit日志长度计数器Datepicker将最后一个日志另存为缓存和TB-Logs的模板,如果您离开页面而不保存日志,则警告该邮件形式邮件签名复选框的保存状态好友列表其他链接缓存数量为链接到发现列表链接到画廊链接到隐藏的缓存自上次访问以来发现的缓存数量书签“在google地图中显示”-链接收藏夹-列表显示缓存类型和总和的统计信息字段注释“全部选中”-复选框显示缓存类型和日志类型的统计信息用于保存PQ的Pocket Queries F2(如果由书签列表创建)将替换PQ-Name。 支持语言:English

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值