我有一个应用程序,它根据相似性对字符串数组进行分组。它是从 TomCat 服务器公开的,启动参数是
/usr/lib/jvm/java/bin/java -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/username/shared/log/heapdump.log -XX:-UseAdaptiveSizePolicy -XX:NewRatio=3 -Xms8192M -Xmx8192M -XX:+UseParNewGC -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:/home/username/shared/log/gc.log -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=7896 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -classpath :/usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar:/usr/share/java/commons-daemon.jar -Dcatalina.base=/usr/share/tomcat7 -Dcatalina.home=/usr/share/tomcat7 -Djava.endorsed.dirs= -Djava.io.tmpdir=/var/cache/tomcat7/temp -Djava.util.logging.config.file=/usr/share/tomcat7/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager org.apache.catalina.startup.Bootstrap start
我的 GC 日志是这样的
316.795: [GC 316.795: [ParNew: 233516K->15658K(249216K), 0.0143200 secs] 1899624K->1683370K(8360960K), 0.0143830 secs] [Times: user=0.17 sys=0.00, real=0.02 secs]
我的 GC 日志中不断出现(并发模式失败)错误。我相信,这是因为年轻一代的规模很小。我试图将新生代与新生代的比例设置为3:1,但是从日志中可以看出,新生代的大小仍然是249216K。
为什么 JVM 不遵守 -XX:NewSize
选项?
最佳答案
看看这个guide , 特别是
The Young Generation
部分:
By default, the young generation size is controlled by NewRatio. For example, setting -XX:NewRatio=3 means that the ratio between the young and tenured generation is 1:3. In other words, the combined size of the eden and survivor spaces will be one fourth of the total heap size.
看起来你设置的比例与预期的相反
关于java - 在 JVM 中为字符串处理应用程序设置新生代和终身代的比例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15523471/