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 70368 - MainProjectAction instances are attached listening on OpenProjectList and leaking
Summary: MainProjectAction instances are attached listening on OpenProjectList and lea...
Status: VERIFIED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Generic Projects UI (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: Jan Lahoda
URL:
Keywords: PERFORMANCE
Depends on: 70539
Blocks: 70032
  Show dependency tree
 
Reported: 2005-12-13 23:47 UTC by Antonin Nebuzelsky
Modified: 2005-12-22 13:42 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
OptimizeIt screenshot (79.64 KB, image/png)
2005-12-13 23:49 UTC, Antonin Nebuzelsky
Details
Proposed patch. (3.90 KB, patch)
2005-12-19 08:40 UTC, Jan Lahoda
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antonin Nebuzelsky 2005-12-13 23:47:28 UTC
See the attached OptimizeIt screenshot where you can see a call stack for an
instance of MainProjectAction which was created for purposes of New Action
wizard. The instance (and few other instances) are however leaking forever
because in constructor of MainProjectAction a property change listener is
attached to OpenProjectList (see the reference path on the OptimizeIt
screenshot). This keeps these instances living.
Comment 1 Antonin Nebuzelsky 2005-12-13 23:49:01 UTC
Created attachment 27808 [details]
OptimizeIt screenshot
Comment 2 Antonin Nebuzelsky 2005-12-13 23:55:36 UTC
The same problem applies to also other actions in the package
org.netbeans.modules.project.ui.actions. When profiling the New Action wizard I
see also leaking instances of RecentProjects and SetMainProject using the same
mechanism. Looking at other classes in the package, I see this should be fixed
also for example in CloseProject action. Please, fix on all places.
Comment 3 Jan Lahoda 2005-12-14 14:59:07 UTC
The actions should use a weak listener, IMO.
Comment 4 Jesse Glick 2005-12-14 16:19:14 UTC
Note that we could change BadgingSupport to try to load the instance from the
live Repository.default if a FileObject with the same path exists there and that
FileObject shares the same attribute names. That would allow the SFS to provide
the cached live instance of the MainProjectAction for use in the wizard, which
would prevent this bug even without using weak listeners since a new instance of
MPA would not be created.

We cannot fully check that attribute *values* are equivalent since there is no
way to ask FileObject for an unevaluated version of a methodvalue/newvalue attr.
So this logic would be a bit off in case someone had an action in the running
development IDE declared like

<file name="whatever.instance">
    <attr name="instanceCreate" methodvalue="some.Clazz.create"/>
</file>

which produces an Action instance with label "Some Action", but then edited the
layer.xml source to read

<file name="whatever.instance">
    <attr name="instanceCreate" methodvalue="some.other.Clazz.create"/>
</file>

which would (if run) produce an Action "Some Other Action". Currently "Some
Other Action" would be displayed (if some.other.Clazz can be found) but with
such a change we would incorrectly display "Some Action".

However such a bug would be very obscure so I would not consider it a blocker.
If you think that would be a useful approach, either reassign this bug to me (if
you do not want to do a weak listener fix in release50) or file a fresh RFE for
me to impl in the trunk (if you do).
Comment 5 Antonin Nebuzelsky 2005-12-16 08:53:47 UTC
I vote for fixing this now using the weak listeners in trunk and in release50
branch. Then we could change to the more sophisticated approach in trunk for
next release.
Comment 6 Jesse Glick 2005-12-16 21:48:40 UTC
Fine by me. I filed issue #70539.
Comment 7 Jan Lahoda 2005-12-18 15:03:39 UTC
IMO, the actions should listen weak. The main project actions can be created as
necessary (through MainProjectActions), and some of the other actions are
context sensitive actions, which may be also created as necessary.

I will prepare a patch for 5.0.
Comment 8 Jan Lahoda 2005-12-19 08:39:08 UTC
Fixed in the trunk:
src/org/netbeans/modules/project/ui/actions/MainProjectAction.java:1.12->1.13
src/org/netbeans/modules/project/ui/actions/RecentProjects.java:1.14->1.15
src/org/netbeans/modules/project/ui/actions/SetMainProject.java:1.9->1.10

Jesse, could you please review the patch (will attach it).

Tonda, could you please verify that the change helps?

QA, do you agree with this change?
Comment 9 Jan Lahoda 2005-12-19 08:40:33 UTC
Created attachment 27927 [details]
Proposed patch.
Comment 10 Jesse Glick 2005-12-19 16:50:46 UTC
Patch looks fine to me.
Comment 11 Antonin Nebuzelsky 2005-12-20 12:26:02 UTC
Verified that the fix works in trunk.
Please, proceed with backporting to release50 branch. Thanks.
Comment 12 Jaromir Uhrik 2005-12-20 14:04:41 UTC
I agree with integration to release50 branch.
Comment 13 Jan Lahoda 2005-12-21 13:43:43 UTC
Fixed in release50 branch too:
Checking in src/org/netbeans/modules/project/ui/actions/MainProjectAction.java;
/cvs/projects/projectui/src/org/netbeans/modules/project/ui/actions/MainProjectAction.java,v
 <--  MainProjectAction.java
new revision: 1.12.52.1; previous revision: 1.12
done
Checking in 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.14.4.1; previous revision: 1.14
done
Checking in src/org/netbeans/modules/project/ui/actions/SetMainProject.java;
/cvs/projects/projectui/src/org/netbeans/modules/project/ui/actions/SetMainProject.java,v
 <--  SetMainProject.java
new revision: 1.9.4.1; previous revision: 1.9
done
Comment 14 Antonin Nebuzelsky 2005-12-22 13:42:52 UTC
Verified in 5.0 (build 200512212030).