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.
Each start-finish of debugger leaves a memory leak. See the attached list of debugger objects which have accumulated after 2 restarts of debugger on jEdit project. I will also attach reference chains for Session and JPDADebuggerImpl instances, both from the first run of the debugger and from the second run of the debugger (the reference chains in these cases differ).
Created attachment 26626 [details] List of leaking instances from the debugger packages
Created attachment 26627 [details] Reference graph of the older Session instance
Created attachment 26628 [details] Reference graph of the newer Session instance
Created attachment 26629 [details] Reference graph of the older JPDADebuggerImpl instance
Created attachment 26630 [details] Reference graph of the newer JPDADebuggerImpl instance
Martine, let me know if I can give you more information from the profiler...
This seems to be a regression caused by the map that stores actions which are to be disabled in toolbar when an action is running.
I've identified two problems: a HashMap in JPDADebuggerActionProvider and lastDebugger field in EvaluateAction. Both use weak references now: /cvs/debuggerjpda/ui/src/org/netbeans/modules/debugger/jpda/ui/actions/EvaluateAction.java,v <-- EvaluateAction.java new revision: 1.4; previous revision: 1.3 /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/actions/JPDADebuggerActionProvider.java,v <-- JPDADebuggerActionProvider.java new revision: 1.10; previous revision: 1.9 The mem. leak should not occur now, please verify.
The accumulating leak is gone. However there is still temporary leak (until another instance of JPDA debugger is run). As you can see at the OptimizeIt screenshots I'll attach, the reference path keeping all the stuff in memory is JPDADebuggerImpl <- IOManager <- DebuggerOutput (a static variable). This should be fixed as well because if the user does not run debugger any more, the objects are kept in memory.
Created attachment 26802 [details] List of temporarily leaking instances from the debugger packages
Created attachment 26803 [details] List of temporarily leaking instances from the debugger packages
Created attachment 26804 [details] OptimizeIt screenshot
The DebuggerOutput is holding a set of IOManagers. This is because it will close the old Debugger Console window when a new session is started. The Debugger Console stays opened even after the debugger finishes - for information purposes. IMHO the correct fix here is to hold the JPDADebugger instance weakly in IOManager, so that it can be released after the debugger session has finished.
Things were much easier at the end, the debugger field in IOManager was not used at all. Therefore I've removed it and it should hopefully finally solve the mem. leak problem: /cvs/debuggerjpda/ui/src/org/netbeans/modules/debugger/jpda/ui/DebuggerOutput.java,v <-- DebuggerOutput.java new revision: 1.27; previous revision: 1.26 /cvs/debuggerjpda/ui/src/org/netbeans/modules/debugger/jpda/ui/IOManager.java,v <-- IOManager.java new revision: 1.16; previous revision: 1.15
Verified. Thanks.