commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
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 (
       Date: Sun, 26 Sep 2004 5:40 PM
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

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

View the issue:

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
             core / taglib.core

   Reporter: Hans Gilde

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

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.

This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:

If you want more information on JIRA, or have a bug to report see:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message