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
"With or Without You" features sustained guitar parts played by guitarist the Edge with a prototype of the Infinite Guitar, along with vocals by lead singer Bono and a bassline by bassist Adam Clayton.
Harmonically speaking, “With Or Without You” is a simple four-bar loop that repeats unchanged for the entire duration of the song. This loop-based structure is standard for electronic dance music and hip-hop, but it was less common in rock back in 1987.
-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
.
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)
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.
Here is some information:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With