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 125335 - WebProject memory leak in JSFFrameworkProvider
Summary: WebProject memory leak in JSFFrameworkProvider
Status: VERIFIED FIXED
Alias: None
Product: obsolete
Classification: Unclassified
Component: visualweb (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: _ potingwu
URL:
Keywords: PERFORMANCE
Depends on:
Blocks: 123530
  Show dependency tree
 
Reported: 2008-01-16 01:47 UTC by Quy Nguyen
Modified: 2008-01-18 20:25 UTC (History)
0 users

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 Quy Nguyen 2008-01-16 01:47:43 UTC
WebProject[C:\Sun\rave\perf\UniversityCrudApp]:
private static java.util.HashMap
org.netbeans.modules.visualweb.project.jsf.framework.JSFFrameworkProvider.propertyListeners->
java.util.HashMap@1a37931-table->
[Ljava.util.HashMap$Entry;@1aaec1a-[12]->
java.util.HashMap$Entry@1f5f0b3-key->
org.netbeans.modules.web.project.WebProject@6187dd


To reproduce:
1) Open a visual web project
2) Open and close a page (may not be necessary)
3) Close the project

The WebProject object is still being held in the propertyListeners map.  An examination of the JSFFrameworkProvider
source shows that listeners are never removed from the map.
Comment 1 _ potingwu 2008-01-16 17:30:04 UTC
Fixed in the trunk. Use WeakHashMap for holding the project property change listener instead of HashMap.

BTW, it's a recent regression that is not in the NetBeans 6.0 release.
Comment 2 Quy Nguyen 2008-01-16 23:08:57 UTC
The WeakHashMap is keyed on the WebProject instance, but the WebProject instance is reachable from the map entry's
value.  This prevents the entry from being automatically removed.  The GC root path is below:

WebProject[C:\Documents and Settings\qn145415\My Documents\NetBeansProjects\WebApplication65]:
private static final java.util.Map
org.netbeans.modules.visualweb.project.jsf.framework.JSFFrameworkProvider.propertyListeners->
java.util.WeakHashMap@fb12ab-table->
[Ljava.util.WeakHashMap$Entry;@1c08758-[3]->
java.util.WeakHashMap$Entry@93c018-value->
java.util.ArrayList@e1b81e-elementData->
[Ljava.lang.Object;@1c282fe-[0]->
org.netbeans.modules.visualweb.project.jsf.ui.JSFNodeFactory$JSFNodeList@f5aa7a-project->
org.netbeans.modules.web.project.WebProject@1254e91
Comment 3 _ potingwu 2008-01-18 20:10:00 UTC
Don't declare static for the HashMap and don't static cache JSFFrameworkProvider to prevent memory leak.

Now I don't see JSFFrameworkProvider in the Run-time Watches list.
Comment 4 Quy Nguyen 2008-01-18 20:25:40 UTC
It looks like the leak is fixed.  However, you should consider using a normal HashMap instead of WeakHashMap since it
doesn't work as expected anyway.