2 Awesome Tips for Reducing Memory Usage in JMeter
It's super important to know how to reduce JMeter memory usage. Especially for high performance testing.
The JMeter is OutOfMemory error, which occurs during report generation is one the most common problem during performance testing (with JMeter).
The misnomer here is that while folks complain that it's JMeter consuming loads of memory like a teenage boy consumes food, and it's simply not the whole story.
The actual problem is simultaneous load and report generation, which are not necessarily compatible.
Take for example Tsung, another open source performance testing tool with low memory required and you may notice that unlike JMeter, you can't see charts and graphics of the load during a test run. Tsung writes all test results into a file and you can generate the report only AFTER the test run completes.
JMeter makes it possible to genarate reports and see graphics during a load run, which is all too often regarded as a flaw. However, if you do a bit o' research about about tuning JMeter scripts, you'll notice that the listeners are what causes the OutOfMemory errors.
So, what are our option?ve options for them.
Exclude Listeners from JMeter Scripts
Our best recommendation as to what you should do with listeners is to exclude them from your test plan completely.
As mentioned, generating load and a report at the same time is not the best practice. We will use Tsung's default report generation technique, i.e. only collecting test results into the file and then we'll analyze them post test.
First, add these lines into the user.properties file:
These lines declare the type of results that will be saved and in which format. After this add the "Simple Data Writer" listener at the end of your test plan. Insert the name of your file and filepath to collected results. If you click the "Configure" button, you can see the changes by the lines added into the user.properties file.
Don't forget to exclude other listeners.
And now, we can start our test. To analyze them simply add any listener, for example "Graph Results", click the "Browse" button and choose your report file. That's it.
Check out our free JMeter academy for 'loads' more info.