在 JVM 中测量花费在 GC 上的时间
假设我正在测试一个 Java 服务器应用程序.我知道完成考试需要多少时间.现在我想知道在那次测试期间在 GC 上花了多少钱.我该怎么做?
Suppose I am testing a Java server application. I know how much time it takes to finish the test. Now I'd like to know how much was spent on GC during that test. How can I do it?
推荐答案
最简单的方法是启动时使用-Xloggc
和-XX:-PrintGCTimeStamps
选项你的JVM.我认为它会打印出垃圾收集需要多长时间.
The simplest way is to use the -Xloggc
and -XX:-PrintGCTimeStamps
options when starting up your JVM. I think it prints out how long garbage collection takes.
http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
相关文章