Bug 44022 - Memory Leak when closing test plan
Memory Leak when closing test plan
Status: RESOLVED FIXED
Product: JMeter
Classification: Unclassified
Component: Main
2.3.1
PC Linux
: P2 major (vote)
: ---
Assigned To: JMeter issues mailing list
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2007-12-04 16:35 UTC by Jaroslav Bachorik
Modified: 2007-12-05 11:22 UTC (History)
0 users



Attachments
Should fix memory leak when closing test plans (3.01 KB, patch)
2007-12-05 02:12 UTC, Jaroslav Bachorik
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jaroslav Bachorik 2007-12-04 16:35:55 UTC
Steps to reproduce:
1. Open the forEachTestPlan.jmx demo plan
2. Run it few times
3. Close the test plan

Result:
If you take a heap dump and analyze it in a tool (jhat eg.) you can see there
are HttpSampleResult objects dangling. 

I've analyzed the situation and there are at least 2 causes:
1. nodesToGui map in the GuiPackage class - this needs to be properly cleaned up
once the test plan is closed
2. also a ViewResultsFullVisualizer instance containing HttpSampleResults
objects is kept alive by the reference from the ResultCollector.listener field

I tried to come up with an easy fix but especially the cause nr.2 is tightly
connected to the jmeter architecture so it'd be better if someone with deeper
understanding of it would take a look at this issue
Comment 1 Jaroslav Bachorik 2007-12-05 02:12:13 UTC
Created attachment 21231 [details]
Should fix memory leak when closing test plans

Plz, review the patch whether it doesn't affect other functionality
Comment 2 Sebb 2007-12-05 03:53:18 UTC
Thanks very much - the patch looks good.
{I like the way you moved the clearTestPlan() call into GuiPackage. Neat.)
Comment 3 Sebb 2007-12-05 04:09:17 UTC
Unit testing shows a problem with the AbstractListener patch - clone() causes 
an NPE. 
However, that is easy to fix, just use:
   clone.listener=this.listener;
instead of:
   clone.setListener(getVisualizer());

[clone() should probably have been coded that way originally.]
I'll try some more tests and apply the patch if all goes well.
Comment 4 Sebb 2007-12-05 11:22:51 UTC
Seems to work OK, so added to SVN in 0.

Had to make one more change, as the listener may not be present:

    protected final Visualizer getVisualizer() {
        if (listener == null){ // e.g. in non-GUI mode
                return null;
        }
        return (Visualizer)listener.get();