Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 345290 - memory leak when doing successive redeploy of webappContext due to not invalidated session in server
Summary: memory leak when doing successive redeploy of webappContext due to not invali...
Status: RESOLVED FIXED
Alias: None
Product: Jetty
Classification: RT
Component: server (show other bugs)
Version: 7.4.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 7.2.x   Edit
Assignee: Greg Wilkins CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 336449 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-05-10 12:01 EDT by Ludovic Praud CLA
Modified: 2011-07-25 10:34 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ludovic Praud CLA 2011-05-10 12:01:46 EDT
Build Identifier: 7.2.2.v20101205

possible duplicate of 336449

I use jetty for my integration tests. In order to optimize tests duration, I start the server and do only webappContext redeploy.

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.

I can provide source code to reproduce the problem if required.

Reproducible: Always

Steps to Reproduce:
1.run jetty server without webappContext
2.deploy a webappContext
3.make the webapp create session
4.undeploy webappContext but keep the server
5.goto step 2 until OutOfMemoryException PermGen space
Comment 1 Jesse McConnell CLA 2011-05-10 12:07:35 EDT
if your embedding jetty for your unit tests you could call the invalidate yourself

just a thought if this is a major issue for you, or are you using jetty in another way for this sort of testing?
Comment 2 Ludovic Praud CLA 2011-05-10 12:24:16 EDT
It is not a major issue for me because I found a workaround by changing the server sessionIdManager before starting another webappContext :

server.setSessionIdManager(new HashSessionIdManager());

I agree this is not the way I use jetty on production environment but still, it would be cool to prevent such OOM because it always cost time to find where it come from.
Comment 3 Greg Wilkins CLA 2011-05-11 22:16:39 EDT
I've reworked the hash session managers to

a) always remove the sessions on doStop
b) use weak references from the session id manager (just in case).

This is checked in at r3123.

I would really appreciate if you could test this ASAP so we can see if it can go into 7.4.1
Comment 4 Ludovic Praud CLA 2011-05-12 04:54:08 EDT
I've tested 7.4.1-SNAPSHOT, removing my workaround before of course.

It works great. I stressed it a little and every thing work smoothly. The webappContext loaded classes are well garbaged each time the webappContext is undeployed.

You were really fast, thanks.

Just for making some advertizing, I went through this leak when working with this plugin http://code.google.com/p/mycila/wiki/PluginJetty which uses jetty as embedded container for webapp integration testing.
Comment 5 Michael Gorovoy CLA 2011-07-25 10:34:41 EDT
*** Bug 336449 has been marked as a duplicate of this bug. ***