如何将详细垃圾收集输出重定向到文件?

编程入门 行业动态 更新时间:2024-10-19 14:49:29
本文介绍了如何将详细垃圾收集输出重定向到文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何将详细垃圾收集输出重定向到文件? Sun的网站显示了一个Unix的例子,但它不适用于Windows。 java -X :

-Xloggc:< file>将GC状态记录到带有时间戳的文件

记录:

-Xloggc:文件名 em>

设置文件以将日志冗长的GC事件信息重定向到该文件。写入此文件的信息类似于从每个记录的事件之前的第一个GC事件开始经过的时间, -verbose:gc 的输出。 -Xloggc 选项将覆盖 -verbose:gc ,如果两者都使用相同的 java 命令。

示例:

-Xloggc:垃圾收集。日志

所以输出看起来像这样: 278K(5056K),0.0096650秒] 0.906:[GC 1174K-> 774K(5056K),0.0106856秒] 1.320:[GC 1670K - > 1009K(5056K),0.0101132秒] 1.459:[GC 1902K-> 1055K(5056K),0.0030196秒] 1.600:[GC 1951K-> 1161K(5056K),0.0032375秒] 1.686:[GC 1805K-> 1238K(5056K),0.0034732秒] 1.690:[全GC 1238K-> 1238K(5056K),0.0631661秒] 1.874:[GC 62133K-> 61257K 65060K),0.0014464秒]

How do I redirect verbose garbage collection output to a file? Sun’s website shows an example for Unix but it doesn't work for Windows.

解决方案

From the output of java -X:

-Xloggc:<file> log GC status to a file with time stamps

Documented here:

-Xloggc:filename

Sets the file to which verbose GC events information should be redirected for logging. The information written to this file is similar to the output of -verbose:gc with the time elapsed since the first GC event preceding each logged event. The -Xloggc option overrides -verbose:gc if both are given with the same java command.

Example:

-Xloggc:garbage-collection.log

So the output looks something like this:

0.590: [GC 896K->278K(5056K), 0.0096650 secs] 0.906: [GC 1174K->774K(5056K), 0.0106856 secs] 1.320: [GC 1670K->1009K(5056K), 0.0101132 secs] 1.459: [GC 1902K->1055K(5056K), 0.0030196 secs] 1.600: [GC 1951K->1161K(5056K), 0.0032375 secs] 1.686: [GC 1805K->1238K(5056K), 0.0034732 secs] 1.690: [Full GC 1238K->1238K(5056K), 0.0631661 secs] 1.874: [GC 62133K->61257K(65060K), 0.0014464 secs]

更多推荐

如何将详细垃圾收集输出重定向到文件?

本文发布于:2023-07-06 07:36:20,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   重定向   垃圾   文件   详细

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!