-XX:MaxPermSize有或没有-XX:PermSize。

时间:2023-01-23 17:19:46

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.

我们遇到了一个Java.lang。OutOfMemoryError: PermGen空间错误并查看tomcat JVM params,而不是-Xms和-Xmx params,我们还指定-XX:MaxPermSize=128m。在进行了一些分析之后,我可以看到在PermGen空间中偶尔会发生垃圾收集,从而节省了运行的时间。

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?

我的问题是:除了增加-XX:MaxPermSize之外,如果我指定了-XX:PermSize,那将会有什么不同?我知道总内存将是Xmx+maxPermSize,但是还有其他原因吗? xx:指定了maxPermSize时,PermSize不应该在那里?

Please do share if you have real-world experience dealing with these JVM parameters.

如果您有处理这些JVM参数的实际经验,请分享。

ps. The JVM is HotSpot 64bit Server VM build 16.2-b04

JVM是HotSpot 64位Server VM构建的16.2-b04。

3 个解决方案

#1


43  

-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.

PermSize指定将在JVM启动时分配的初始大小。如果需要,JVM将分配到-XX:MaxPermSize。

#2


25  

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.

通过使用参数as - xx:PermSize和- xms,您可以对应用程序的启动进行优化。我最近都没看,但几年前xms的默认值是32 mb(我认为),如果您的应用程序需要大量,它将触发一个多周期的填充内存-完整的垃圾收集增加内存等之前加载所需的一切。这个循环可能不利于启动性能,因此立即分配所需的数量可以改善启动。

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.

警告JVM有很多优化和智能分配内存时,把伊甸园空间和老一辈人等,所以做事情不喜欢xms等于- xmx或- xx:PermSize等于- xx:MaxPermSize因为它会删除一些优化的JVM可以适用于它的分配策略,因此降低而不是提高应用程序性能。

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)

和往常一样:用非平凡的度量来证明您的更改实际上提高了总体性能(例如,在使用应用程序时,改进启动时间可能会对性能造成灾难性的影响)

#3


7  

If you're doing some performance tuning it's often recommended to set both -XX:PermSize and -XX:MaxPermSize to the same value to increase JVM efficiency.

如果您正在进行一些性能调优,通常建议将两个-XX:PermSize和-XX:MaxPermSize设置为相同的值,以提高JVM效率。

Here is some information:

这里有一些信息:

  1. Support for large page heap on x86 and amd64 platforms
  2. 支持x86和amd64平台上的大页面堆。
  3. Java Support for Large Memory Pages
  4. 对大内存页的Java支持。
  5. Setting the Permanent Generation Size
  6. 设置永久的生成大小。

You can also specify -XX:+CMSClassUnloadingEnabled to enable class unloading option if you are using CMS GC. It may help to decrease the probability of Java.lang.OutOfMemoryError: PermGen space

您还可以指定-XX:+CMSClassUnloadingEnabled来启用类卸载选项,如果您正在使用CMS GC。它可能有助于降低Java.lang的概率。OutOfMemoryError:PermGen空间

#1


43  

-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.

PermSize指定将在JVM启动时分配的初始大小。如果需要,JVM将分配到-XX:MaxPermSize。

#2


25  

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.

通过使用参数as - xx:PermSize和- xms,您可以对应用程序的启动进行优化。我最近都没看,但几年前xms的默认值是32 mb(我认为),如果您的应用程序需要大量,它将触发一个多周期的填充内存-完整的垃圾收集增加内存等之前加载所需的一切。这个循环可能不利于启动性能,因此立即分配所需的数量可以改善启动。

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.

警告JVM有很多优化和智能分配内存时,把伊甸园空间和老一辈人等,所以做事情不喜欢xms等于- xmx或- xx:PermSize等于- xx:MaxPermSize因为它会删除一些优化的JVM可以适用于它的分配策略,因此降低而不是提高应用程序性能。

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)

和往常一样:用非平凡的度量来证明您的更改实际上提高了总体性能(例如,在使用应用程序时,改进启动时间可能会对性能造成灾难性的影响)

#3


7  

If you're doing some performance tuning it's often recommended to set both -XX:PermSize and -XX:MaxPermSize to the same value to increase JVM efficiency.

如果您正在进行一些性能调优,通常建议将两个-XX:PermSize和-XX:MaxPermSize设置为相同的值,以提高JVM效率。

Here is some information:

这里有一些信息:

  1. Support for large page heap on x86 and amd64 platforms
  2. 支持x86和amd64平台上的大页面堆。
  3. Java Support for Large Memory Pages
  4. 对大内存页的Java支持。
  5. Setting the Permanent Generation Size
  6. 设置永久的生成大小。

You can also specify -XX:+CMSClassUnloadingEnabled to enable class unloading option if you are using CMS GC. It may help to decrease the probability of Java.lang.OutOfMemoryError: PermGen space

您还可以指定-XX:+CMSClassUnloadingEnabled来启用类卸载选项,如果您正在使用CMS GC。它可能有助于降低Java.lang的概率。OutOfMemoryError:PermGen空间