This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 191041 - Memory leak in JsfSupport.INSTANCIES
Summary: Memory leak in JsfSupport.INSTANCIES
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: JSF Editor (show other bugs)
Version: 7.0
Hardware: PC Linux
: P2 normal (vote)
Assignee: Marek Fukala
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2010-10-15 19:35 UTC by Jesse Glick
Modified: 2010-11-30 06:14 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2010-10-15 19:35:37 UTC
JsfSupport.INSTANCIES [sic] is a WeakHashMap<WebModule,JsfSupport> and therefore relies on the JsfSupport not holding a strong reference to the WebModule. Yet JsfSupport holds a strong reference to a ClassPath which in practice holds a strong reference to a Project which probably has a strong reference to its WebModule. Therefore none of these things can be collected.

Observed in a heap dump from an IDE run which did not release some projects after being closed.

Consider whether the static cache is really necessary. Since JsfSupport seems to hold no nonrecoverable state, and does not appear to perform any significant computation, it may suffice to just create a fresh one whenever requested.
Comment 1 Marek Fukala 2010-11-23 16:22:44 UTC
The static weak hash map doesn't work, that's true, but there are some data which requires lots of time to find and compute so I need a way how to bind them to a reasonable object to be able to access them by clients.

Simplest way would be to bind to the project itself. I can do that for web projects, but still ... isn't there a way how one can attach objects to a generic project? I haven't found anything reasonable in the project's lookup.
Comment 2 Jesse Glick 2010-11-23 19:17:05 UTC
(In reply to comment #1)
> isn't there a way how one can attach objects to a generic project?

No, I don't think so.

Simplest fix is just a WeakHashMap<WebModule,WeakReference<JsfSupport>>. Does not prevent the JsfSupport from getting recalculated, but makes it less likely. You might want to add a comment to http://bugs.sun.com/view_bug.do?bug_id=6389107 that yet another use case has been found.
Comment 3 Marek Fukala 2010-11-29 18:23:14 UTC
fixed in web-main#7494f6ef00b8. 

The JsfSupport instance are now held in project's lookup.
Comment 4 Quality Engineering 2010-11-30 06:14:38 UTC
Integrated into 'main-golden', will be available in build *201011300001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/7494f6ef00b8
User: Marek Fukala <mfukala@netbeans.org>
Log: #191041 -  Memory leak in JsfSupport.INSTANCIES; Also an initial version the jsf friend api module. Still needs to be polished and documented a bit. Some other parts from jsf support and jsf support editor are going to be moved there.