Bob Meliev is a Contributing Writer to the BlazeMeter blog

Learn JMeter in 5 Hours

Start Learning
Slack

Test Your Website Performance NOW!

arrow Please enter a valid URL
Feb 02 2014

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:
 
jmeter.save.saveservice.output_format=csv
jmeter.save.saveservice.data_type=false
jmeter.save.saveservice.label=true
jmeter.save.saveservice.response_code=true
jmeter.save.saveservice.response_data.on_error=false
jmeter.save.saveservice.response_message=false
jmeter.save.saveservice.successful=true
jmeter.save.saveservice.thread_name=true
jmeter.save.saveservice.time=true
jmeter.save.saveservice.subresults=false
jmeter.save.saveservice.assertions=false
jmeter.save.saveservice.latency=true
jmeter.save.saveservice.bytes=true
jmeter.save.saveservice.hostname=true
jmeter.save.saveservice.thread_counts=true
jmeter.save.saveservice.sample_count=true
jmeter.save.saveservice.response_message=false
jmeter.save.saveservice.assertion_results_failure_message=false
jmeter.save.saveservice.timestamp_format=HH:mm:ss
jmeter.save.saveservice.default_delimiter=;
jmeter.save.saveservice.print_field_names=true
 
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. 
 
JMeter's Simple Data Writer listener
 
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.
 

Learn More

Check out our free JMeter academy for 'loads' more info.

     
arrow Please enter a valid URL

You might also find these useful:

Interested in writing for our Blog?Send us a pitch!

We're working on starting your first test

Testing 20 Virtual Users

Starting your test in around 2-4 minutes. Your report will appear once we've gathered the data.

0

Status: Preparing Your Test

Your email is required to complete the test. If you proceed, your test will be aborted.