GC Tools

  • There are multiple ways to enable the GC log: specifying either of the flags -verbose:gc 
    or -XX:+PrintGC will create a simple GC log (the flags are aliases for each other, and by 
    default the log is disabled).
  • The -XX:+PrintGCDetails flag will create a log with much more information. This flag is recommended (it is also false by default); it is often too difficult to diagnose what is happening with GC using only the simple log
  • In conjunctionwith the detailed log, it is recommended to include -XX:+PrintGCTimeStamps or 
    -XX:+PrintGCDateStamps, so that the time between GC operations can be determined. The difference in those two arguments is that the timestamps are relative to 0 (based on when the JVM starts), while the date stamps are an actual date string. That makes the date stamps ever-so-slightly less efficient as the dates are formatted, though it is an infrequent enough operation that its effect is unlikely to be noticed.
  • The GC log is written to standard output, though that location can be changed with the 
    -Xloggc:filename flag. Using -Xloggc automatically enables the simple GC log unless 
    PrintGCDetails has also been enabled. The amount of data that is kept in the GC log 
    can be limited using log rotation; this is quite useful for a long-running server that 
    might otherwise fill up its disk with logs over several months. Logfile rotation is 
    controlled with these flags: -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=N 
    -XX:GCLogFileSize=N. By default, UseGCLogFileRotation is disabled. When that flag 
    is enabled, the default number of files is 0 (meaning unlimited), and the default logfile 
    size is 0 (meaning unlimited). Hence, values must be specified for all these options in 
    order for log rotation to work as expected. Note that a logfile size will be rounded up to 
    8 KB for values less than that.
  • For a scriptable solution, jstat is the tool of choice. jstat provides nine options to 
    print different information about the heap; jstat -options will provide the full list. 
    One useful option is -gcutil, which displays the time spent in GC as well as the percentage 
    of each GC area that is currently filled. Other options to jstat will display the 
    GC sizes in terms of KB.
  • Remember that jstat takes an optional argument—the number of milliseconds to repeat 
    the command—so it can monitor over time the effect of GC in an application. Here 
    is some sample output repeated every second: jstat -gcutil process_id 1000

Summary

  • GC logs are the key piece of data required to diagnose GC issues; 
    they should be collected routinely (even on production 
    servers).
  • A better GC logfile is obtained with the PrintGCDetails flag.
  • Programs to parse and understand GC logs are readily available; 
    they are quite helpful in summarizing the data in the GC 
    log.
  • jstat can provide good visibility into GC for a live program.

GC Tools的更多相关文章

  1. 【转】gc日志分析工具

    性能测试排查定位问题,分析调优过程中,会遇到要分析gc日志,人肉分析gc日志有时比较困难,相关图形化或命令行工具可以有效地帮助辅助分析. Gc日志参数 通过在tomcat启动脚本中添加相关参数生成gc ...

  2. Spark的Straggler深入学习(1):如何在本地图形监控远程Spark的GC情况——使用java自带的jvisualvm

    一.本文的目的       Straggler是目前研究的热点,Spark中也存在Straggler的问题.GC问题是总所周知的导致Straggler的重要因素之一,为了了解GC导致的Straggle ...

  3. GC之七--gc日志分析工具

    性能测试排查定位问题,分析调优过程中,会遇到要分析gc日志,人肉分析gc日志有时比较困难,相关图形化或命令行工具可以有效地帮助辅助分析. Gc日志参数 通过在tomcat启动脚本中添加相关参数生成gc ...

  4. Android 内存分析工具 - LogCat GC

    一.GC_Reason 触发垃圾回收的回收的集中原因: 类型 描述 GC_CONCURRENT 内存使用将满时,并发的进行垃圾回收. GC_FOR_MALLOC 当内存已满应用尝试分配内存时会出触发垃 ...

  5. Java GC系列(4):垃圾回收监视和分析

    本文由 ImportNew - lomoxy 翻译自 javapapers. 目录 垃圾回收介绍 垃圾回收是如何工作的? 垃圾回收的类别 垃圾回收监视和分析 在这个Java GC系列教程中,让我们学习 ...

  6. Java 8 VM GC Tunning Guide Charter 7-8-b

    第七章 并发gc Java 8提供两种并发gc,CMS和G1 Concurrent Mark Sweep (CMS) Collector This collector is for applicati ...

  7. [译]GC专家系列2:Java 垃圾回收的监控

    原文链接:http://www.cubrid.org/blog/dev-platform/how-to-monitor-java-garbage-collection/ 这是"成为GC专家系 ...

  8. Java GC专家系列2:Java 垃圾回收的监控

    这是”成为GC专家系列”文章的第二篇.在第一篇理解Java垃圾回收中我们学习了几种不同的GC算法的处理过程,GC的工作方式,新生代与老年代的区别.到目前为止,你应该已经了解了JDK 7中的5种GC类型 ...

  9. troubleshooting tools in JDK 7--转载

    This chapter describes in detail the troubleshooting tools that are available in JDK 7. In addition, ...

随机推荐

  1. MongoDB初了解——用户权限

    本文所述MongoDB版本为4.0.5,笔者对MongoDB刚接触,对各个版本的MongoDB不甚了解,本文不对该版本的MongoDB做特性介绍,所涉及命令也许对其余版本不适用. 因为目前有一个试验性 ...

  2. 给zTree的treeNode添加class

    onNodeCreated 回调,捕获 DOM 创建完毕的回调,然后利用 zTree 的规则找到 treeNode.tId + "_a" 这样的 标签,自行添加 class 就是了 ...

  3. 动态BGP和静态BGP的含义与区别

    1.在华为云上选购虚拟机时,会让用户选择动态BGP还是静态BGP, 全动态BGP可根据设定的寻路协议第一时间自动优化网络结构,以保持客户使用的网络持续稳定.高效. 静态BGP中的网络结构发生变化,运营 ...

  4. Python之--paramiko实例

    一.基于SFTPClient类连接sshd服务器: 特点: 一般用于实现对远程服务器的上传, 下载和对远程目录文件的操作 import pramiko hostname = '172.24.0.110 ...

  5. ssh服务突然连接不了案例总结

    ssh服务突然连接不了案例总结   一台Oracle数据库服务器(Linux版本为Oracle Linux Server release 5.7)今天中午突然出现短暂的ssh连接不上的情况,ssh连接 ...

  6. 常用SMTP地址

    1.QQ邮箱(mail.qq.com) POP3服务器地址:pop.qq.com(端口:110) SMTP服务器地址:smtp.qq.com(端口:25) 2.搜狐邮箱(sohu.com): POP3 ...

  7. SQLServer之视图简介

    视图定义 视图是一个虚拟表,其内容由查询定义. 同表一样,视图包含一系列带有名称的列和行数据. 视图在数据库中并不是以数据值存储集形式存在,除非是索引视图. 行和列数据来自由定义视图的查询所引用的表, ...

  8. LeetCode算法题-Repeated String Match(Java实现)

    这是悦乐书的第289次更新,第307篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第156题(顺位题号是686).给定两个字符串A和B,找到A必须重复的最小次数,使得B是 ...

  9. Spark-RDD之Partition源码分析

    概要 Spark RDD主要由Dependency.Partition.Partitioner组成,Partition是其中之一.一份待处理的原始数据会被按照相应的逻辑(例如jdbc和hdfs的spl ...

  10. idea怎么配置spring

    前提基础: 1.idea软件并JDK成功能用 2.有tacate,并会导入. 3.了解jsp和mvc基本结构 详细介绍: https://www.cnblogs.com/wormday/p/84356 ...