Ori Marko
Ori Marko

Reputation: 58882

JMeter - OutOfMemoryError when retrieving million records in JDBC request

When I'm trying to get above million records in JDBC request, I get an OutOfMemoryError:

 ERROR o.a.j.JMeter: Uncaught exception: 
java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Unknown Source) ~[?:1.8.0_191]
    at java.lang.AbstractStringBuilder.ensureCapacityInternal(Unknown Source) ~[?:1.8.0_191]
    at java.lang.AbstractStringBuilder.append(Unknown Source) ~[?:1.8.0_191]
    at java.lang.StringBuilder.append(Unknown Source) ~[?:1.8.0_191]
    at java.lang.StringBuilder.append(Unknown Source) ~[?:1.8.0_191]
    at org.apache.jmeter.protocol.jdbc.AbstractJDBCTestElement.getStringFromResultSet(AbstractJDBCTestElement.java:563) ~[ApacheJMeter_jdbc.jar:5.1.1 r1855137]
    at org.apache.jmeter.protocol.jdbc.AbstractJDBCTestElement.execute(AbstractJDBCTestElement.java:175) ~[ApacheJMeter_jdbc.jar:5.1.1 r1855137]
    at org.apache.jmeter.protocol.jdbc.sampler.JDBCSampler.sample(JDBCSampler.java:84) ~[ApacheJMeter_jdbc.jar:5.1.1 r1855137]
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622) ~[ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546) ~[ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486) ~[ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253) ~[ApacheJMeter_core.jar:5.1.1 r1855137]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_191]

Is there such a limitation in JDBC? Is it JMeter bug which should stop execution with relevant error?

For example, for smaller records it returns

Response too large to be displayed. Size: 26848889 > Max: 10485760, Start of message:

Upvotes: 0

Views: 422

Answers (2)

Bilal Demir
Bilal Demir

Reputation: 686

Open bin/jmeter.sh on linux or bin/jmeter.bat on windows, find this line and remove it from the comment line:

JVM_ARGS="-Xms512m -Xmx512m"

This variable is passed as arguments to jmeter at startup. Increase the default heapsize like this:

JVM_ARGS="-Xms1024m -Xmx1024m"

You could add more space if you needs more.

Upvotes: 0

monhelm
monhelm

Reputation: 169

Out of Memory is not a JMeter bug ... it means your JMeter process runs out of memory. If using Windows, have a look at following section in your jmeter.bat

    if not defined HEAP (
    rem See the unix startup file for the rationale of the following parameters,
    rem including some tuning recommendations
    set HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m
    )

You might want to have a search around Stackoverflow as well for issues with JMeter heap space - an example: JMeter OutOfMemoryError

Be aware that the "Results Tree View" is not designed to display millions of records but for script (aka test plan) development. I for my part would parameterize the number of records and use a small number for development and just use the larger numbers for actual testing (non-gui mode etc).

Upvotes: 1

Related Questions