增加maxpermsize和max heap size的副作用 [英] side effect for increasing maxpermsize and max heap size

查看:656
本文介绍了增加maxpermsize和max heap size的副作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以解释增加maxpermsize和max heap size的副作用吗?

Can anybody explain the side effects for increasing the maxpermsize and max heap size?

我知道有时候,当我们遇到outofmemory问题时,我们会增加-Xmx。但我只是想知道当我们增加-Xmx时是否需要记住任何副作用。增加maxpermsize会如何影响运行时?

I know that sometimes, we increase -Xmx when we run into the outofmemory issue. But I am just wondering if there is any side effect that I need to keep in mind when we increase the -Xmx. And how does increasing maxpermsize affect the runtime?

谢谢。

推荐答案

简短回答

加倍Java堆大小,使垃圾收集暂停的等待时间加倍,当前的JVM技术变为多秒堆是Gb顺序。似乎新发布的 Java 7将改变这种情况

Doubling java heap size, doubles the waiting time for Garbage Collection pauses, that with current JVM technologies become of multiple seconds when the heap is in the Gb order. It seems that the newly released Java 7 is going to change that.

长答案

MaxPermSize 是最大尺寸对于永久生成堆,一个堆,它保存类的字节代码,并与包含实际实例的对象堆保持分离。在Web应用程序的情况下要记住的一件事是,在每次热重新部署时,这些内存使用量将随着相同类的多个副本而增加。除非指定-XX:+ CMSClassUnloadingEnabled。

The MaxPermSize is the maximum size for the permanent generation heap, a heap that holds the byte code of classes and is kept separated from the object heap containing the actual instances. One thing to keep in mind in case of web applications, is that in each hot re-deployment this memory usage is going to increase with multiple copies of the same classes. Unless -XX:+CMSClassUnloadingEnabled is specified.

最大堆大小( - Xmx)和MaxPermSize必须考虑到内存量应用程序类和实例,服务器的总内存以及其他应用程序所需的内存需要它。

Max Heap Size (-Xmx) and MaxPermSize have to be set taking into consideration how much memory is needed by the application classes and instances, the total memory of the server and the memory needed by other applications.

另一个重点是从最小堆大小( - Xms)是一项代价高昂的操作。特别是在金融应用的情况下,这可能意味着延迟。对于类似的实时要求,将-Xms和-Xmx设置为相同的值可能是个好主意。

Another important point is that expanding the memory from the Min Heap Size (-Xms) is a costly operation. Especially in case of financial applications this could mean delays. With similar real-time requirements, it could be a good idea to set -Xms and -Xmx to the same value.

下面的话题可能会引起关注 http://www.infoq.com/presentations/Java-without-the-GC-暂停

The following talk may be of interest http://www.infoq.com/presentations/Java-without-the-GC-Pauses

从谈话中你可以看出,增加堆的副作用超过一定限制2Gb,10Gb,100Gb,意味着更长的暂停时间垃圾收集,如果堆积很大,可能会停止几秒钟或一分钟。

From the talk you can evince that the side effect of increasing the heap more than a certain limit 2Gb, 10Gb, 100Gb, means longer pause time for Garbage Collection that could stop everything for seconds or a minute in case of very large heaps.

因此,对于当前JVM技术,您希望将堆设置得足够大运行你的应用程序,但不是太大。找到合适大小的方法,可以将其设置为最大可能值,然后切成两半并保持切成两半,直到找到问题,当你这样做时,将最后找到的值加倍并保持为所选的堆大小用于生产。

For that reason with current JVM technology, you want to set the heap large enough to run your application, but not too large. A way to find the right size, could be set it to the largest possible value, then cut in half and keeping on cutting in half until you find problems, when you do, double the last found value and keep it as the chosen heap size for production.

这个建议当然适用于大堆,按Gb顺序,如果你的应用程序运行正常,256Mb的内存,我会保留该值而无需进一步调查。

This advice of course applies for large heaps, in the Gb order, if your application runs fine with 256Mb of memory, I would just keep that value without further investigation.

最后供参考的是一些示例设置:

And finally for reference here are some example settings:

-Xms512m -Xmx512m -XX:MaxPermSize=256m -XX:+CMSClassUnloadingEnabled

这篇关于增加maxpermsize和max heap size的副作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆