commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From commons-...@jakarta.apache.org
Subject [jira] Updated: (JELLY-148) Huge memory leak resulting from the use of ThreadLocal
Date Mon, 27 Sep 2004 00:40:32 GMT
The following issue has been updated:

    Updater: Hans Gilde (mailto:hansgilde@earthlink.net)
       Date: Sun, 26 Sep 2004 5:40 PM
    Comment:
I just uploaded thread-local-memory-leak-fix-demo-parent.txt. This patch still needs JavaDoc
and a unit test and isn't ready to be applied for real. I'm hoping to see if people like the
idea first.

I'm not thrilled with the idea of caching stuff in the JellyContext because it opens up the
problems of having to explicitly clear the cache or throw out the JellyContext after every
use. Having to do either would force me to change my own, existing embedded Jelly code, so...
I'm trying to avoid it. :)

This is an alternate solution that I really like. My first solution was to prevent any tag
from keeping a hard reference to any TagScript (like the tag's body). This works fine, except
when tags want to keep a reference to their body script.

The new solution is this: prevent tags from keeping hard references to their *parents*. All
references to parents become weak. This eliminates the memory leak. It also doesn't break
tags that want to execute their bodies at a later time. Except that... the bodies become headless.
In other words, if a tag (like Swing's ActionTag) keeps it's body script, the body script
may not be able to find parents. It will, though, have full access to its context. Basically,
if you keep a reference to a tag's body script, you still can't prevent the tag's parent from
being GC'd.

Although this all might sound complicated, it seems to me that it's simpler than the scenarios
that arise with caching in the JellyContext. In a future verison of Jelly, we can make proper
API changes to allow caching in the JellyContext and to generally support caching in a better
way.

    Changes:
             Attachment changed to thread-local-memory-leak-fix-demo-parent.txt
    ---------------------------------------------------------------------
For a full history of the issue, see:

  http://issues.apache.org/jira/browse/JELLY-148?page=history

---------------------------------------------------------------------
View the issue:
  http://issues.apache.org/jira/browse/JELLY-148

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: JELLY-148
    Summary: Huge memory leak resulting from the use of ThreadLocal
       Type: Bug

     Status: Unassigned
   Priority: Critical

    Project: jelly
 Components: 
             core / taglib.core
   Versions:
             1.0-beta-5

   Assignee: 
   Reporter: Hans Gilde

    Created: Sat, 18 Sep 2004 9:34 PM
    Updated: Sun, 26 Sep 2004 5:40 PM

Description:
There is a huge memory leak that results from the TagScript's use of ThreadLocal.

ThreadLocal is usually used from a staic variable, while TagScript uses it from an instance
variable. Although this looks legal to me, it causes a huge memory leak.


---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message