Jyothish
Jyothish

Reputation: 39

On downloading 1GB file, Uncaught Exception java.lang.OutOfMemoryError in JMeter

I'm using Jmeter 5.2.1 with HTTP Request to capture performance of a 1GB file download. On executing the script in Non-GUI mode, am receiving below error -

java.lang.OutOfMemoryError: Java heap space Dumping heap to java_pid7536.hprof ... Heap dump file created [555071109 bytes in 17.048 secs] Uncaught Exception java.lang.OutOfMemoryError: Java heap space in thread Thread[Thread Group 1-1,5,main]

jmeter.bat has property "set HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m"

I don't have any listeners in the jmx file and using non-GUI mode to test. May i know what changes i need to do in order to have successsful response

Upvotes: 1

Views: 832

Answers (2)

sbos61
sbos61

Reputation: 564

In addition to Dmitri'suggestions, I would add that this method is ok for one or may two downloads, but it is not scalable at all if want to test ten or more parallel downloads. IMHO, a better solution would be to check "Save response as MD5 hash?" in the HTTP controller.

If this is selected, then the response is not stored in the sample result. Instead, "the MD5 hash of the data is calculated and stored instead" (from the manual) This is intended for testing large amounts of data. The advantage is that the data is not stored in memory.

Upvotes: 0

Dmitri T
Dmitri T

Reputation: 168002

If you're downloading a file it is temporarily stored in memory, it means that you need at least 1 GB of HEAP for each JMeter concurrent thread (virtual user) in order to be able to retrieve the file.

Edit the jmeter.bat file and change the upper heap limit -Xmx to a higher value. For 1 virtual user giving 2 gigabytes will be sufficient like:

set HEAP=-Xms1g -Xmx2g -XX:MaxMetaspaceSize=256m

JMeter restart will be required to pick up the change.

References:

Ideally JMeter's heap consumption should be between 30% and 80% of JVM heap, the actual number varies depending on the nature of your test, just monitor the heap usage using i.e. JVisualVM to ensure that JMeter doesn't spend too much time doing garbage collection

Upvotes: 1

Related Questions