OutOfMemory PermGen Errors

In the past I’ve gone to the good old reliable “-XX:MaxPermSize=256m” (or 384m, 512m, etc.) to try to get redeploys in webapp containers like Tomcat and Glassfish to allow numerous hot-redeploys. I figured I’d invest a little time in sorting this out to see if there’s a better solution – unfortunately it doesn’t look like it.


had some useful sounding suggestions:

  • Move to JRockit – which is free for deployment (minus the nice management console) and does look very impressive, and seems to use a different memory scheme that doesn’t rely on PermGen, but could conceivably still suffer from class/memory leaks
  • Try these flags: -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled – this seems not to work, at least when tested against JDK 6, Glassfish 3, with a Spring-based application with a moderate amount of open-soruce tooling (Spring, Log4j, Drools, the like) – with PermGen set to 256m I still get out of Memory, and jvisualvm shows PermGen slowly filling up:

    permgen filling up

In the end, I have to agree with: http://my.opera.com/karmazilla/blog/2007/03/13/good-riddance-permgen-outofmemoryerror – it looks like we’re stuck with this, at least I haven’t found a sane solution beyond restarting between deploys. At least embedded servers like jetty or embedded glassfish startup quicker…