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?!?).
Apparently, the perm is a storage area of classes that are loaded in the JVM. It seems that the default garbage collection cycle we had configured within our jvm config file did not clear up permanent generation memory. Hence it just kept growing and growing, eventually running out of allocated memory.
This issue is quite common, but finding a cure was quite a pain in the A#@$! All we had to do was add some arguments to the jvm.config file of the application server.
- Add ‘-XX:+UseConcMarkSweepGC’. This is specifing to use the concurrent collector instead of the standard one, which can’t collect in the permanent generation.
- Now add ‘-XX:+CMSPermGenSweepingEnabled’. This tells the collector to collect the perm gen.
- Finally add ‘-XX:+CMSClassUnloadingEnabled’. This tells the collector to allows Java classes to be unloaded.
- Ensure that you give your perm memory a decent allocation by adding the following line in your config file: ‘-XX:MaxPermSize=256m’.
This should, in theory, solve your Perm Gen OutOfMemory error. (Fingers crossed)
