[英]Garbage Collection - Changing Collector Algorithm
We are running our Spring+Hibernate web app on Tomcat (Java 1.5). 我们在Tomcat(Java 1.5)上运行Spring + Hibernate Web应用程序。 Currently we use 2GB of heap space (I am told it is the max possible on Solaris 32 bit servers although Server has a total of 16GB RAM). 目前我们使用2GB的堆空间(我被告知它是Solaris 32位服务器上的最大可能,尽管Server总共有16GB RAM)。 The current JAVA_OPTS are : 目前的JAVA_OPTS是:
-XX:MaxPermSize=512m -XX:+UseParallelGC -Xms2048m -Xmx2048m -XX:MaxPermSize = 512m -XX:+ UseParallelGC -Xms2048m -Xmx2048m
The Young Gen + Survivor space is ~600 MB and Old Gen is 1.4 GB. Young Gen + Survivor空间约为600 MB,Old Gen为1.4 GB。
There are time when the memory gets full and we need to restart Tomcat. 有时间内存已满,我们需要重启Tomcat。 The following are the observations: 以下是观察结果:
We would like to change to the following JAVA_OPTIONS - I need feedback on whether this is sensible choice (UAT environments do not match the load of Prod env and we are unable to replicate the same in UAT) 我们想更改为以下JAVA_OPTIONS - 我需要反馈是否这是明智的选择(UAT环境与Prod env的负载不匹配,我们无法在UAT中复制相同的内容)
Add -Xmn1024m - This is to make sure that the Young Gen objects don't easily get promoted to Old Gen. Any suggestions on increasing / decreasing this ? 添加-Xmn1024m - 这是为了确保Young Gen对象不容易升级为Old Gen.有关增加/减少这个的任何建议吗? Also this would lead to more Young Gen GC and lesser Old Gen GC. 这也将导致更多的Young Gen GC和较小的Old Gen GC。
-XX:+UseParallelOldGC - This is to make the Young and Old Gen GC run multiple threads so that they gets GCed quicker. -XX:+ UseParallelOldGC - 这是为了让Young和Old Gen GC运行多个线程,以便更快地获得GC。
Is the limitation of 2GB applicable to Solaris Servers too ? 2GB的限制是否也适用于Solaris服务器? Cant the heap be increased to more than 2GB ? 堆不能增加到超过2GB?
Please share your thoughts on the above. 请分享您对上述内容的看法。
Thanks, Midhun 谢谢,Midhun
If you experienced too long major collections pause you should consider use -XX:+UseConcMarkSweepGC
(and also keeping the -XX:+UseParallelOldGC
) in order to perform GC concurrently. 如果您经历了太长时间的主要集合暂停,则应考虑使用-XX:+UseConcMarkSweepGC
(并保留-XX:+UseParallelOldGC
)以便同时执行GC。
The fact you use -Xms2048m -Xmx2048m
can be a bad idea, if those values are not quite good you don't let the JVM scales them (but if your sure no problem). 您使用-Xms2048m -Xmx2048m
的事实可能是一个坏主意,如果这些值不是很好,您不要让JVM扩展它们(但如果您确定没问题)。 In Java Performance Tuning 2nd Ed. 在Java性能调优第二版中。 5 frequent suggestion are made about heap size : 关于堆大小的5个常见建议:
- Set the starting heapsize the same as the max heap size 将起始堆大小设置为与最大堆大小相同
- Set the starting size to the size needed by the max number of alive objects and set the max to 4 times this amount 将起始大小设置为最大活动对象数所需的大小,并将最大值设置为此数量的4倍
- Set the starting heap to max heap size 将起始堆设置为最大堆大小
- Set the starting heap size between 1/10 and 1/4 the max heap size 将起始堆大小设置为最大堆大小的1/10到1/4
- Use the default initial heap size 使用默认的初始堆大小
(Try to find the best for you) (尽量找到最适合你的)
This doc give good advice to resolve GC issue , read carrefully paragraphe about Generation Size Adjustments and try some of the command to print your GC activity, some of them can really be helpful to see some bottlenecks in your app or in your GC config. 本文提供了解决GC问题的良好建议,仔细阅读有关生成大小调整的一些命令,并尝试使用某些命令打印您的GC活动,其中一些可以帮助您查看应用程序或GC配置中的一些瓶颈。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.