如何处理GC日志文件过大的情况

Handling large log files produced by long running Java Applications

https://bugs.java.com/bugdatabase/view_bug.do?bug_id=6941923

 

This RFE addresses the a problem faced by long running (one or more months) Java applications generating large log files that exhaust available disk storage.

This RFE introduces a new flag  -XX:logfilesize=n and its usage is described as follows:


 -Xloggc:somefile  -XX:logfilesize=n

  If  the value of n is 0 or is not set then current behavior.

  else

  if  n is positive, close  somefile when its size reaches n and direct
  GC log to somefile.1 until its size reaches n, close somefile.1 and
  dirct GC log to somefile.2 etc.

  A OS specific background (provided by the user) can monitor closed log files
  and move them to back up storage.

  else

  if n is negative perform circular logging when the file size equals abs(n)

introduced three flags:

1) -XX:+UseGCLogRotation must be used with -Xloggc:<filename>

2) -XX:NumberOfGClogFiles=<number of files> must be >=1, default is one

3) -XX:GCLogFileSize=<number>M (or K) default will be set to 512K

if UseGCLogRotation set and -Xloggc gives file name, do Log rotation, depends on other flag settings. if NumberOfGClogFiles = 1, using same file, rotate log when reaches file capicity (set by GCLogFileSize) in <filename>.0 if NumberOfGClogFiles > 1, rotate between files <filename>.0, <filename>.1, ..., <filename>.n-1 GC output through outputStream, we have multiple threads, vmThread, CMS threads, GC worker threads. Check if need rotation at every safepoint. When stop world (at safepoint), changing file handle is safe, else need grab lock to do the change. i.e. tty_lock.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值