本文介绍了我如何看到java正在使用哪个垃圾收集器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java虚拟机支持多种垃圾收集策略。



这篇现在我想知道我的应用程序正在使用哪种策略(自动选择),有没有什么办法让JVM(版本1.6)打印这些信息?

编辑:JVM检测它是否处于客户端或服务器模式。所以问题是我怎样才能看到哪些已被检测到?

http://java.sun.com/j2se/1.5.0/docs/guide/vm/ gc-ergonomics.html ,它适用于J2SE 6,并指出默认值是Parallel Collector。



我们在JVM 1.5上测试过一次,只设置

  -server -Xms3g -Xmx3g -XX:PermSize = 128m -XX:LargePageSizeInBytes = 4m -verbose:gc -XX:+ PrintGCDetails -XX:+ PrintGCTimeStampps 

并显示输出

41359.597:[GC [PSYoungGen:90499K-> 32K(377344K )] 268466K-> 181862K(2474496K),0.0183138秒]
41359.615:[完整GC [PSYoungGen:32K-> 0K(377344K)] [PSOldGen:181830K-> 129760K(2097152K)] 181862K-> 129760K(2474496K )[PSPermGen:115335K-> 115335K(131072K)],4.4590942秒]

其中PS代表并联清除


The Java Virtual Machine supports several garbage collection strategies.

This article explains them.

Now I am wondering which (automatically selected) strategy my application is using, is there any way to let the JVM(version 1.6) print this information?

Edit: The JVM detects if it is in client or server mode. So the question really is how can I see which has been detected?

解决方案

http://java.sun.com/j2se/1.5.0/docs/guide/vm/gc-ergonomics.html which is applicable for J2SE 6 as well states that the default is the Parallel Collector.

We tested this once on a JVM 1.5 by setting only

-server -Xms3g -Xmx3g -XX:PermSize=128m -XX:LargePageSizeInBytes=4m -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps

and the output showed

41359.597: [GC [PSYoungGen: 90499K->32K(377344K)] 268466K->181862K(2474496K), 0.0183138 secs]
41359.615: [Full GC [PSYoungGen: 32K->0K(377344K)] [PSOldGen: 181830K->129760K(2097152K)] 181862K->129760K(2474496K) [PSPermGen: 115335K->115335K(131072K)], 4.4590942 secs]

where PS stands for Parallel Scavenging

这篇关于我如何看到java正在使用哪个垃圾收集器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 07:02