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 50572

Summary: MainClassUpdater hanging around after project closed
Product: projects Reporter: Antonin Nebuzelsky <anebuzelsky>
Component: Generic InfrastructureAssignee: Antonin Nebuzelsky <anebuzelsky>
Status: CLOSED FIXED    
Severity: blocker CC: issues, pnejedly
Priority: P2 Keywords: PERFORMANCE
Version: 4.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on:    
Bug Blocks: 41535, 49247    
Attachments: MainClassUpdater instances not disposed

Description Antonin Nebuzelsky 2004-10-18 17:13:32 UTC
After an opened project is closed its
MainClassUpdater instance keeps hanging around.
However, all I see in OptimizeIt is a reference
path through WeakListenerImpl$PropertyChange to
ProjectProperties:

MainClassUpdater <- element of ArrayList <-
elementData  of WLI$PropertyChange <- listeners of
PropertyUtils$SequentialPropertyEvaluator <-
standardPropertyEvaluator of ProjectProperties <-...

I don't see any direct hard reference.
Investigation of the code at
J2SEProject$ProjectOpenedHookImpl.projectOpened()
(J2SEProject.java:361) does not reveal any local
variable holding a reference to it either.

Petre, could you please have a look at this in
INSANE? Maybe you'll find a reference path
OptimizeIt does not show me.... Thanks.
Comment 1 Petr Nejedly 2004-10-19 13:50:58 UTC
Here is the reference chain:

org.netbeans.modules.project.ui.OpenProjectList.INSTANCE->
org.netbeans.modules.project.ui.OpenProjectList@f5b->
java.util.ArrayList@279f->
[Ljava.lang.Object;@41c7->
org.netbeans.modules.java.j2seproject.J2SEProject@715c->
org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@cdaa->
[Lorg.netbeans.spi.project.support.ant.PropertyProvider;@147f6->
org.netbeans.spi.project.support.ant.ProjectProperties$UserPropertiesProvider@c9b2->
org.netbeans.spi.project.support.ant.PropertyUtils$FilePropertyProvider@26ed->
java.util.ArrayList@3f20->
[Ljava.lang.Object;@6d84->
org.netbeans.spi.project.support.ant.ProjectProperties$UserPropertiesProvider@c9b3->
org.netbeans.spi.project.support.ant.ProjectProperties@dee9->
org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@dedc->
java.util.ArrayList@155e8->
[Ljava.lang.Object;@1c1e4->
org.netbeans.modules.java.j2seproject.MainClassUpdater@238d0

Not only MainClassUpdater is kept but also a bunch of other objects
including the J2SEProject:

org.netbeans.modules.project.ui.OpenProjectList.INSTANCE->
org.netbeans.modules.project.ui.OpenProjectList@f5b->
java.util.ArrayList@279f->
[Ljava.lang.Object;@41c7->
org.netbeans.modules.java.j2seproject.J2SEProject@715c->
org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@cdaa->
[Lorg.netbeans.spi.project.support.ant.PropertyProvider;@147f6->
org.netbeans.spi.project.support.ant.ProjectProperties$UserPropertiesProvider@c9b2->
org.netbeans.spi.project.support.ant.PropertyUtils$FilePropertyProvider@26ed->
java.util.ArrayList@3f20->
[Ljava.lang.Object;@6d84->
org.netbeans.spi.project.support.ant.ProjectProperties$UserPropertiesProvider@c9b3->
org.netbeans.spi.project.support.ant.ProjectProperties@dee9->
org.netbeans.spi.project.support.ant.AntProjectHelper@813d->
org.netbeans.api.project.ProjectManager$ProjectStateImpl@dee5->
org.netbeans.modules.java.j2seproject.J2SEProject@8139

It seems to me that the problem is sharing the user properties.
Comment 2 Jesse Glick 2004-10-19 16:28:47 UTC
OPL should not hold a ref to the prj when the prj is closed.
Comment 3 Petr Hrebejk 2004-10-19 16:47:28 UTC
It does not. According to Petr Nejedly he had two projects unrelated
projects. He kept one open (the one referenced from OPL) and opened
and closed the other one. 
The second one seems to be hold in memory through some listener on
ProjectProperties.
Comment 4 Jesse Glick 2004-10-19 17:11:55 UTC
Forgotten WeakListeners usage, I think.
Comment 5 Jesse Glick 2004-10-19 19:04:39 UTC
committed   * Up-To-Date  1.24       
ant/project/src/org/netbeans/spi/project/support/ant/PropertyUtils.java
committed   * Up-To-Date  1.14       
ant/project/test/unit/src/org/netbeans/spi/project/support/ant/PropertyUtilsTest.java

Found a fixed one leak, please verify that this fixed the problem or
file a new issue with a new leak chain.
Comment 6 Petr Nejedly 2004-10-20 10:28:45 UTC
The closed project is still referenced:

org.netbeans.modules.project.ui.OpenProjectList.INSTANCE->
org.netbeans.modules.project.ui.OpenProjectList@1475->
java.beans.PropertyChangeSupport@2e5d->
java.util.Vector@4ae8->
[Ljava.lang.Object;@839c->
org.netbeans.modules.project.ui.actions.RecentProjects@dcf2->
javax.swing.JMenu@151f8->
javax.swing.JPopupMenu@1c0e1->
[Ljava.awt.Component;@24379->
javax.swing.JMenuItem@2e8cf->
java.util.Hashtable@34d29->
[Ljava.util.Hashtable$Entry;@38a89->
java.util.Hashtable$Entry@3b379->
org.netbeans.modules.java.j2seproject.J2SEProject@7e96

Strange that Insane haven't found this shorter reference chain before.
A newly introduced leak? Reassigning to phrebejk.
Comment 7 Petr Hrebejk 2004-10-20 15:51:32 UTC
Yet another reference fixed. Let's see what will come next. Please verify.

Checking in
projectui/src/org/netbeans/modules/project/ui/actions/RecentProjects.java;
/cvs/projects/projectui/src/org/netbeans/modules/project/ui/actions/RecentProjects.java,v
 <--  RecentProjects.java
new revision: 1.9; previous revision: 1.8
done
Comment 8 Petr Nejedly 2004-10-21 15:58:26 UTC
Finally fixed now.
Comment 9 Antonin Nebuzelsky 2004-10-22 16:35:59 UTC
Disagree. You perhaps fixed something else than what this issue
originally was about. :) I still see cumulating instances of
MainClassUpdater when I repeatedly open and close a project.

The reduced reference graph in OptimizeIt just shows one reference
path. Seee the attached screenshot.
Comment 10 Antonin Nebuzelsky 2004-10-22 16:39:03 UTC
Created attachment 18454 [details]
MainClassUpdater instances not disposed
Comment 11 Petr Nejedly 2004-10-22 22:15:22 UTC
It was OK for my test case.
Anyway, Projects can hardly fix the reference chain you posted, as the
source file from the project is held by MDR.
How much are they accumulating? How is the accumulation affected by
the size of the AST cache?
Comment 12 Petr Hrebejk 2004-10-25 17:05:58 UTC
Please insane it again with petr and if assign to who ever maintains
the code holding that object.

Thanks
Comment 13 Antonin Nebuzelsky 2004-11-03 14:54:50 UTC
Setting back to FIXED. The instances are hagning there only temporarily.
Comment 14 Jaromir Uhrik 2005-07-14 16:19:07 UTC
Verified.