[SOLVED] How can I find and isolate the cause for a jmeter script's increased memory consumption over time?

Issue

I have created a JMeter script with 2 Thread groups. One keeps Putting multiples messages on an IBM MQ queue1 and then still at runtime, another one Gets and consumes the responses to each of these messages from another IBM MQ queue2.

The purpose is to generate load and measure the response times for all messages. For this goal, in order to synchronize the threads, I am using the Inter Thread Communication Plugin to pass the JMScorrelationID of each message from threads operating on queue1 (producers) to threads operation on queue2 (consumers).
To do this I use JSR223 samplers with groovy code and these two libraries:

javax.jms-api-2.0.1
com.ibm.mq.allclient-9.2.0.2

To put the messages on queue1 I am using mainly these methods:

javax.jms.Session.createProducer(destinationInboundQueue)
//code to create some text payload
javax.jms.TextMessage.createTextMessage(payload)
javax.jms.MessageProducer.send(aboveMessage)

To consume the response messages from queue2 I am using mainly these methods:

javax.jms.Session.createConsumer(destination, "JMSCorrelationID='" + queue1MessageId + "'" )
javax.jms.MessageConsumer.receive(10000) 

At first it seems to work fine, but the problem is that the longer I run the script, even with a constant given load, the more RAM it occupies as the times passes. I can see this in the Windows Task Manager – The Memory usage under "Java(TM) Platform Se binary" is increasing over time at a steady rate. At some point, I get close to 90% of the memory and I think that is when errors start to occur.
Also it seems that the longer I run the script, the more time is spent by Jmeter to consume target messages from the queue – this might be a side-effect of the increasing memory usage.
I think that this is not normal.

I’ve looked at the code and I can’t figure out what the cause for this is.

If anyone knows, I would like to know (in Jmeter), how I could debug and isolate what part in my groovy script is causing the ram to get filled up over time.

Thanks in advance.

Solution

Sounds like a classic memory leak, it’s hard to say exactly where without seeing your full code, most probably not closed connection or an object accumulating data and not being a subject to garbage collection or problem in the code causing compilation and class loading of the script by each thread on each iteration.

Only a profiler tool can provide you the answer.

A workaround would be going for Distributed Testing

And make sure to follow JMeter Best Practices

Answered By – Dmitri T

Answer Checked By – Pedro (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *