You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Antony Bowesman <An...@williamhill.com.au> on 2018/04/03 04:03:31 UTC

Cleaning up memory used by an HTTPSampleResult

I've been investigating a memory leak and it seems that under certain circumstances when I get a redirect, I end up downloading a bunch of embedded resources I don't need. In this case, these HTTPSampleResult objects end up being part of my JavaSampler instance, which is added to the TEAR_DOWN_SET in the JavaSampler jmeter class.

In this particular test, the Java Sampler only executes once and so the HTTPSampleResult objects only get cleaned up at the end of the test, when my teardownTest() method is called. However, it also applies to samplers that are called in a OnceOnlyController, which in my case happens to be Login.

I have a couple of solutions, i.e. I know I can prevent the follow redirects to stop the symptoms of this behaviour and I can also put in a hack that will clean up the resources by other samplers in the same thread, but the bigger picture of how to prevent the basic memory leak issue that appears to exist for these hanging HTTPSampleResult objects. The main culprit is the responseData byte[], which basically holds the entire response payload.

There seems to be no message I can listen for (LoopIterationListener/TestIterationListener) to indicate a thread has made its last iteration.

Is there any way to clean up a thread's resources when it is done with. I can't do the cleanup during the iteration as there may be listeners that want the results.

Thanks
Antony


RE: Cleaning up memory used by an HTTPSampleResult

Posted by Antony Bowesman <An...@williamhill.com.au>.
I was unnecessarily hanging on to these SampleResult objects, so have cleaned that up, but the question on how to know that the thread has made its last iteration still stands - any ideas or is this something for dev? It's version 3.3

> -----Original Message-----
> From: Antony Bowesman [mailto:Antony.Bowesman@williamhill.com.au]
> Sent: Tuesday, 3 April 2018 2:04 PM
> To: JMeter Users List <us...@jmeter.apache.org>
> Subject: Cleaning up memory used by an HTTPSampleResult
> 
> I've been investigating a memory leak and it seems that under certain
> circumstances when I get a redirect, I end up downloading a bunch of
> embedded resources I don't need. In this case, these HTTPSampleResult
> objects end up being part of my JavaSampler instance, which is added to the
> TEAR_DOWN_SET in the JavaSampler jmeter class.
> 
> In this particular test, the Java Sampler only executes once and so the
> HTTPSampleResult objects only get cleaned up at the end of the test, when
> my teardownTest() method is called. However, it also applies to samplers
> that are called in a OnceOnlyController, which in my case happens to be
> Login.
> 
> I have a couple of solutions, i.e. I know I can prevent the follow redirects to
> stop the symptoms of this behaviour and I can also put in a hack that will
> clean up the resources by other samplers in the same thread, but the bigger
> picture of how to prevent the basic memory leak issue that appears to exist
> for these hanging HTTPSampleResult objects. The main culprit is the
> responseData byte[], which basically holds the entire response payload.
> 
> There seems to be no message I can listen for
> (LoopIterationListener/TestIterationListener) to indicate a thread has made
> its last iteration.
> 
> Is there any way to clean up a thread's resources when it is done with. I can't
> do the cleanup during the iteration as there may be listeners that want the
> results.
> 
> Thanks
> Antony


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org