VM Perm Out of memory fix
With Coldfusion and Railo applications making Java so easy it is not unusual that you can have 1,000’s of underlying java classes created and this can cause jvm OutOfMemoryError issues relating to the permanent generation space. The perm is like a big database of classes that are loaded in the JVM. Recently we have seen this happen on Railo a number of times, the problem is that by default a JVM garbage collection cycle does not collect permanent generation so it just keeps growing and eventually runs out of memory.
The Fix:
We need to add some arguments to the jvm.config file of the application server.
The standard garbage collector can’t collect in the permanent generation, but the concurrent collector can. So the first thing we need to do is to make sure that the jvm uses the concurrent garbage collector
-XX:+UseConcMarkSweepGC
But this is not enough.
We must also specifically tell it to collect in the permanent generation, and this is done with this command line argument:
-XX:+CMSPermGenSweepingEnabled
Good, now the concurrent collector will take the permantent generation under its wings.
But wait! Classes are special, and the jvm is reluctant to let go of them, so we must also explicitly allow classes to be unloaded:
-XX:+CMSClassUnloadingEnabled
Don’t forget to also give your perm memory a decent allocation of memory
-XX:MaxPermSize=256m
Thanks to Christian Vest Hansen for figuring this out.
I was recently involved in migrating all applications at my work from Coldfusion7 (running on JRUN with Windows) to Railo (running on JBoss within a Linux environment).
There were several teething issues, as can be expected. Most of them were minor except for one which kept giving us grief. This issue would cause our JBoss instances to drop dead, with a ‘Perm Gen OutOfMemory’ error being logged. After much research I found that this issue relates to the ‘permanent generation space’. (The what?!?).
Continue reading ‘OutOfMemoryError’