-XX:MaxPermSize 带或不带 -XX:PermSize
我们遇到了 Java.lang.OutOfMemoryError: PermGen space 错误,并查看了 tomcat JVM 参数,除了 -Xms
和 -Xmx params 我们还指定了
-XX:MaxPermSize=128m
。经过一些分析后,我可以看到 PermGen 空间上偶尔会发生垃圾收集,从而避免它运行满。
我的问题是:除了增加 -XX:MaxPermSize
之外,如果我同时指定 -XX:PermSize
会有什么区别?我知道总内存将为Xmx+maxPermSize,但是还有其他原因导致-XX:PermSize
在时不存在吗? >-XX:MaxPermSize
已指定?
如果您有处理这些 JVM 参数的实际经验,请分享。
附: JVM 是 HotSpot 64 位服务器 VM 版本 16.2-b04
We've run into a Java.lang.OutOfMemoryError: PermGen space error and looking at the tomcat JVM params, other than the -Xms
and -Xmx
params we also specify -XX:MaxPermSize=128m
. After a bit of profiling I can see occasionally garbage collection happening on the PermGen space saving it from running full.
My question is: other than increasing the -XX:MaxPermSize
what would be the difference if I specify as well -XX:PermSize
? I know the total memory then would be Xmx+maxPermSize but is there any other reason why -XX:PermSize
should not be there when -XX:MaxPermSize
is specified?
Please do share if you have real-world experience dealing with these JVM parameters.
ps. The JVM is HotSpot 64bit Server VM build 16.2-b04
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
-XX:PermSize
指定 JVM 启动期间分配的初始大小。如有必要,JVM 将最多分配-XX:MaxPermSize
。-XX:PermSize
specifies the initial size that will be allocated during startup of the JVM. If necessary, the JVM will allocate up to-XX:MaxPermSize
.通过使用
-XX:PermSize
和-Xms
等参数,您可以调整应用程序的性能(例如)。我最近没有看过它,但几年前,-Xms
的默认值大约是 32MB(我认为),如果您的应用程序需要的容量远大于此值,则会触发一个数字填充内存的周期 - 完整垃圾收集 - 增加内存等,直到加载完所需的所有内容。此循环可能不利于启动性能,因此立即分配所需的数量可以改进启动。类似的循环也适用于永久代。因此,调整这些参数可以改善启动(等等)。
警告 JVM 在分配内存、划分 eden 空间和老年代等方面有很多优化和智能,因此不要做诸如使
-Xms
相等之类的事情-Xmx
或-XX:PermSize
等于-XX:MaxPermSize
因为它将删除 JVM 可应用于其分配的一些优化策略及其降低而不是提高应用程序性能。一如既往:进行重要的测量来证明您的更改确实提高了整体性能(例如,缩短启动时间可能对应用程序使用期间的性能造成灾难性的影响)
By playing with parameters as
-XX:PermSize
and-Xms
you can tune the performance of - for example - the startup of your application. I haven't looked at it recently, but a few years back the default value of-Xms
was something like 32MB (I think), if your application required a lot more than that it would trigger a number of cycles of fill memory - full garbage collect - increase memory etc until it had loaded everything it needed. This cycle can be detrimental for startup performance, so immediately assigning the number required could improve startup.A similar cycle is applied to the permanent generation. So tuning these parameters can improve startup (amongst others).
WARNING The JVM has a lot of optimization and intelligence when it comes to allocating memory, dividing eden space and older generations etc, so don't do things like making
-Xms
equal to-Xmx
or-XX:PermSize
equal to-XX:MaxPermSize
as it will remove some of the optimizations the JVM can apply to its allocation strategies and therefor reduce your application performance instead of improving it.As always: make non-trivial measurements to prove your changes actually improve performance overall (for example improving startup time could be disastrous for performance during use of the application)
如果您正在进行一些性能调整,通常建议将
-XX:PermSize
和-XX:MaxPermSize
设置为相同的值以增加JVM
> 效率。以下是一些信息:
也可以指定
-XX:+CMSClassUnloadingEnabled
来启用类卸载如果您使用的是
CMS
GC
,请选择此选项。它可能有助于降低Java.lang.OutOfMemoryError: PermGen space
的概率If you're doing some performance tuning it's often recommended to set both
-XX:PermSize
and-XX:MaxPermSize
to the same value to increaseJVM
efficiency.Here is some information:
You can also specify
-XX:+CMSClassUnloadingEnabled
to enable class unloadingoption if you are using
CMS
GC
. It may help to decrease the probability ofJava.lang.OutOfMemoryError: PermGen space