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.
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.
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.
(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.
fixed in web-main#7494f6ef00b8. The JsfSupport instance are now held in project's lookup.
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.