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.
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.
Created attachment 27808 [details] OptimizeIt screenshot
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.
The actions should use a weak listener, IMO.
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).
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.
Fine by me. I filed issue #70539.
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.
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?
Created attachment 27927 [details] Proposed patch.
Patch looks fine to me.
Verified that the fix works in trunk. Please, proceed with backporting to release50 branch. Thanks.
I agree with integration to release50 branch.
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
Verified in 5.0 (build 200512212030).