Bug 37956

Summary: Make 'set static fields to null' ClassLoader leak workaround behaviour configurable
Product: Tomcat 5 Reporter: Taras Tielkes <taras.tielkes>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED DUPLICATE    
Severity: enhancement    
Priority: P5    
Version: 5.5.13   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: Flag for toggling memory leak workaround

Description Taras Tielkes 2005-12-18 19:25:11 UTC
The 5.5.13-beta release includes a workaround for webapp Classloader reference
leaks.
From the changelog:
-------------
(Add code to set to null fields in loaded classes when stopping a web
application, as a possible workaround for suspicious garbage collection
behavior. (remm))
-------------

The workaround minimizes the symtoms, but not the causes of webapp Classloader
leaks.
For purposes of diagnotics, I'd like to be able to revert back to the old
behaviour, with the workaround code disabled.

This behaviour should be configurable, similar to how "antiResourceLocking" and
"antiJARLocking" are configurable on the Context level.
Comment 1 Yoav Shapira 2006-04-13 19:01:37 UTC
Changing to an enhancement request.  Taras, if you feel like submitting a patch,
that'd be great.
Comment 2 Steffen Dienst 2006-06-06 10:45:42 UTC
Hi,

I'd like to vote for this request. We have some problems with redeployment of a 
webapp that seems to result from this workaround. The webapp runs several 
threads (for example within JCS) that use Log4j with commons-logging. After the 
redeployment of the application these threads are trying to access the 
LogManager which results in a NPE as all the fields were set to null. So a 
possibility of disabling of the workaround would be really nice. I seem to have 
a problem accessing the anonymous cvs, so I can't offer any patches, sorry.
Comment 3 Yoav Shapira 2006-06-15 20:10:31 UTC
Is your access to anonymous CVS/SVN better now?
Comment 4 Steffen Dienst 2006-12-20 02:09:35 UTC
Created attachment 19291 [details]
Flag for toggling memory leak workaround

This patch for the container subproject adds a new flag to the context
configuration named "nullifyReferences" that toggles the workaround for memory
leaks on redeployment of webapplications, see changelog of the 5.5.13-beta
release. The default is true.
Comment 5 Steffen Dienst 2006-12-20 02:11:39 UTC
Hi,

thanks for the help. I finally had the time to look into this. I attached a 
patch that adds the flag we needed in the current trunk version. Per default 
the workaround stays enabled. Additionally there was a minor version mismatch 
in the .classpath file.
Comment 6 Mark Thomas 2006-12-20 04:42:36 UTC
Re-opening since the patch has not been committed to SVN.
Comment 7 Thorsten Berger 2007-01-13 11:10:13 UTC
Is there any progress here?
We are facing some serious issues with this memory leak workaround (e.g. using
ojb cross-context prevents redeployment) and would like to see the config option
in one of the next releases.

Regards, Thorsten
Comment 8 Mark Thomas 2007-04-19 20:00:53 UTC
The behaviour will be made optional in TC5.5.x

*** This bug has been marked as a duplicate of 41939 ***