You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2004/07/17 01:54:36 UTC
DO NOT REPLY [Bug 30162] New: -
[PATCH] Avoid potential memory leaks from IntrospectionHelper.helpers
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30162>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=30162
[PATCH] Avoid potential memory leaks from IntrospectionHelper.helpers
Summary: [PATCH] Avoid potential memory leaks from
IntrospectionHelper.helpers
Product: Ant
Version: 1.6.1
Platform: All
OS/Version: All
Status: NEW
Severity: Normal
Priority: Other
Component: Core
AssignedTo: dev@ant.apache.org
ReportedBy: jglick@netbeans.org
IntrospectionHelper keeps a cache of helpers it has made for particular Class's.
This cache is cleared (presumably to avoid leaking memory) when the build
finishes - *if* callers have used the factory method IH.getHelper(Project,Class)
rather than the IH.gH(Class) variant. Unfortunately, if you call only
IH.gH(Class) then the Class references are not released, even by a build finish
event.
This appears to have caused a massive memory leak in the JVM permanent
generation (where classes are held) in the NetBeans IDE. (Workaround: forcibly
clear the cache via reflection.) More:
http://www.netbeans.org/issues/show_bug.cgi?id=43113
Better would be to use a WeakHashMap, since there is no reason to keep a cache
entry if the Class key is referenced only from that entry; it could not possibly
be used. Generally, please be very suspicious of any static fields, especially
maps, and use weak references wherever appropriate.
Attaching a patch which makes the cache weak on the key, and also uses the 2-arg
variant of getHelper wherever it seems it would be possible. (There are some
places where there is no Project context and it is not possible.)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org