How to fixed ERROR - jmeter.threads.JMeterThread: Test failed! java.lang.OutOfMemoryError: unable to create new native thread

Following are the error and solution of “ERROR-jmeter-threads-JMeterThread-Test-failed-java-lang-OutOfMemoryError-unable-to-create-new-native-thread-in-Unix”:

ERROR - jmeter.threads.JMeterThread: Test failed! java.lang.OutOfMemoryError: unable to create new native thread


Error- jmeter.threads.JMeterThread: Test failed! java.lang.OutOfMemoryError: unable to create new native thread
        at java.lang.Thread.start0(Native Method)
        at java.lang.Thread.start(Thread.java:714)
        at sun.net.www.http.KeepAliveCache$1.run(KeepAliveCache.java:112)
        at sun.net.www.http.KeepAliveCache$1.run(KeepAliveCache.java:96)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.net.www.http.KeepAliveCache.put(KeepAliveCache.java:95)
        at sun.net.www.http.HttpClient.putInKeepAliveCache(HttpClient.java:407)
        at sun.net.www.http.HttpClient.finished(HttpClient.java:364)
        at sun.net.www.http.KeepAliveStream.close(KeepAliveStream.java:100)
        at sun.net.www.MeteredStream.justRead(MeteredStream.java:93)
        at sun.net.www.MeteredStream.read(MeteredStream.java:135)
        at java.io.FilterInputStream.read(FilterInputStream.java:133)
        at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3066)
        at org.apache.commons.io.input.ProxyInputStream.read(ProxyInputStream.java:98)
        at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:238)
        at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
        at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:116)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
        at java.io.FilterInputStream.read(FilterInputStream.java:107)
        at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.readResponse(HTTPSamplerBase.java:1745)
        at org.apache.jmeter.protocol.http.sampler.HTTPAbstractImpl.readResponse(HTTPAbstractImpl.java:438)
        at org.apache.jmeter.protocol.http.sampler.HTTPJavaImpl.readResponse(HTTPJavaImpl.java:285)
        at org.apache.jmeter.protocol.http.sampler.HTTPJavaImpl.sample(HTTPJavaImpl.java:516)
        at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
        at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1146)
        at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1135)
        at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:434)
        at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:261)
        at java.lang.Thread.run(Thread.java:745)


Solution:

Add the JVM_ARGS configuration in your apache-jmeter-*.*/bin/jmeter.sh file

e.g. JVM_ARGS="-d64 -Xms24m –Xmx1024m -Xss228k -server"

Change the value of –Xms and –Xmx as per you requirement whereas put the min value of -Xss228k or –Xss64k

And

Change the ulimit –u (unix/REHL/CentOS) value to higher then number, what you have set in your jmeter script attribute num_threads value.

$ulimit -a
core file size           (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 128376
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1024
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

For changing the max user processes need to perform below command:

$ulimit –u 8888

$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 128376
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 8888
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited


That’s all about how to fix the issue. Please like and share it!

Reference: Apache Jmeter

1 comment: