Summary: | Variables not released for GC after JMeterThread exits. | ||
---|---|---|---|
Product: | JMeter - Now in Github | Reporter: | Ronan Klyne <ronan.klyne> |
Component: | Main | Assignee: | JMeter issues mailing list <issues> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | p.mouawad |
Priority: | P2 | ||
Version: | 2.5 | ||
Target Milestone: | --- | ||
Hardware: | All | ||
OS: | All | ||
Attachments: |
Fixes the leaks
Test Plan as explained New fix |
Description
Ronan Klyne
2009-09-30 08:19:14 UTC
Created attachment 27497 [details]
Fixes the leaks
Hello,
I tracked references and I saw 2 remaining issues:
- JMeterThread holds a reference to JMeterVariables through threadVars, at end of thread this one holds data that were added by Samplers . So what I did was to take an image of threadVars at start in a variable called threadVars and then at end of thread, clean all keys that were not here at start , DO YOU SEE ANY CASE THAT WOULD INTRODUCE AN ISSUE ?
- JMeterContext hold a reference to JMeterThread in thread variable which is not reset to null, as this is repositionned in initRun at each run, I can remove if safely I think
Regards
Philippe
Created attachment 27498 [details]
Test Plan as explained
Not sure I agree with the change to JMeterContext - the clear() method may be called other than at the end. I'm not sure why one needs to keep any JMeterVariables at the end of the JMeterThread run - the JMeterThread instance is not re-used - so I would have though it would be OK to clear all the variables. But really I would expect the JMeter Thread to be released at the end of its run, so probably no point even clearing the variables. However that does not seem to be the case. Seems to me the proper fix would be to ensure that the JMeterThread is released on exit, but I don't know what is retaining the reference. Note that the Debug Samplers copy the contents of the variables into their sample results, which are stored by the Tree View Listener. Hello Sebb, I tracked and JMeterThread is finally retained by TestCompiler#pairing which is static and never cleaned once JMeterThread ends. In details: 1) pairing holds a reference to TestCompiler$ObjectPair 2) TestCompiler$ObjectPair holds a reference through child to BSFSampler 3) BSFSampler holds a reference through threadContext to JMeterThread Reading code I don't fully understand the use of pairing. Regards Philippe Again, And there is another reference held through IterationListener (instance class). TestCompiler$ObjectPair>ThreadGroup#propMap>TestElementProperty#savedValue and value>LoopController#iterationListeners. Regards Philippe Created attachment 27499 [details]
New fix
Hello Sebb,
Here is another solution that:
- unregister listener
- nullifies thread reference in clear0
By the way I don't see other calls to clear except JMeterThread#run.
Regards
Philippe
Hello Sebb, Did you have time to look at this one ? Are there still issues in it ? Thank you Regards Thanks for the new patch. There was one raw type, and I localised the iterationListener variable to the run method. URL: http://svn.apache.org/viewvc?rev=1171944&view=rev Log: Bug 47921 - Variables not released for GC after JMeterThread exits. Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/control/Controller.java jakarta/jmeter/trunk/src/core/org/apache/jmeter/control/GenericController.java jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/AbstractThreadGroup.java jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterContext.java jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java jakarta/jmeter/trunk/xdocs/changes.xml Not sure if this is yet enough to fix all the retained objects. Hopefully this is now fixed. If not, please re-open with details. This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2290 |