You can have a OOM on heap space and permanent generation (PermGen) space in your JVM.
The heap space is mainly for short term and mid term memory allocation. The permanent generation space, as named, is for long term object such as class object which are loaded by classLoader and retained during the whole life of the JVM.
But in case of webapp running in a servlet container such as jetty, you sometime need to undeploy and redeploy your application to apply code change. With the mycila-testing-jetty plugin you can choose to either restart your server, redeploy your webapp or keep them running.
During my tests, restarting the server or keeping them runnning them was OK. But I'd always got OOM when keeping the jetty server running and only doing redeploy of the webapp. So I've track down the leak using Eclipse Memory Analyzer and jvisualvm tools.
The error come from how jetty keep sessions.
The problem is that session created during the lifetime of the webappContext are not invalidated on undeploy and so stay in the Server._sessionIdManager keeping all the webappContext class and making OutOfMemoryException PermGen Space happening.
SessionIdManager only invalidate session if the webapp ask it to. I think that except for cluster session management, when undeploying a webappContext then all the session created by it must be invalidated and cleared.
To work around, you can change the server sessionIdManager before redeploying the new webappContext :
server.setSessionIdManager(new HashSessionIdManager());
Bug issue : memory leak when doing successive redeploy of webappContext due to not invalidated session in server
No comments:
Post a Comment