barrymac
barrymac

Reputation: 2760

Is there any way to prevent Grails permgen leaking on redeploy in production mode on tomcat despite JVM flags

It's a familiar old problem but I really want to put it to bed once and for all! I've got the following JVM flags set:

-XX:+CMSClassUnloadingEnabled 
-XX:+CMSPermGenSweepingEnabled -Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=true

but I still observe the permgen usage notch up by a good 50MBs for every deployment cycle. I'm deploying remotely using the Tomcat manager application, and Grails is in production mode.

If it gets too full then a kill -9 is necessary!

I might try using JRockit but nor now it's not an option. I don't really find it acceptable in a production environment to have to bounce the whole container every once in a while.

Upvotes: 4

Views: 718

Answers (2)

Oliver Tynes
Oliver Tynes

Reputation: 964

Permgen leakage is an issue no matter what appserver you're on when using grails is my experience (highly personal and probably easily contendable anecdote, just to be clear on that ;) ).

If this is the only app you have deployed, why not just shutdown.sh, delete webapp folder, put in war and then startup.sh ?

It's the way we go and the redeployment only gains about 7 seconds (where 5 of those are a sleep 5 to ensure catalina is fully shutdown before it goes back up).

Edit:

Having one tomcat instance per app is pretty cool anyways in my opinion!

Upvotes: 2

prusswan
prusswan

Reputation: 7101

You may not be aware of this, but permgem will occur eventually as long as you repeatedly hot deploy to the Tomcat instance, since there are some classes that can never be properly unloaded (either due to the way the classes are programmed, or some limitation on the part of Tomcat) no matter which parameters you use, short of a restart.

Upvotes: 1

Related Questions