1
votes

I need to run a thread test with over 10000 threads but at about 2000, I get the error:

Uncaught Exception java.lang.OutOfMemoryError: unable to create new native thread.

My machine has 8GB ram. I tried

set JVM_ARGS="-Xms1024m -Xmx6144m" jmeter.sh

I didnt change anything in the jmeter.sh file though. Do I need to change anything? What else could I do to run such a large test? How do I run a jmx file without the jmeter gui also? (using mac osx)

2
try running jmeter from console without GUI - nomail
Heap won't help; almost all the space a Thread needs is for its stack, and that does not come from the heap, or even the configurable/measurable non-heap pools, but rather "native" memory. And IME it varies across JVM versions and variants without notice or documentation. Crank -Xss as low as you can without your programs failing, make sure ulimit or similar isn't affecting your processes, and cross your fingers. - dave_thompson_085
@dave_thompson_085 I am a little new to jmeter, could you explain a little bit further on how to set -Xss as low (is it in the jmeter.sh file) and how do I make sure ulimit isnt affecting my process? - Jonatha Suh
-Xss is a Java/JVM startup option; you set it the same way as -Xmx etc. I'm not familiar with jmeter, but @Dmitri's answer looks sensible to me. The hard part is determining the correct value to use, because it depends on the code your threads run; I can't help much there. Operating system limits like ulimit vary depending on your OS which you didn't identify and I don't know all of them anyway; if in doubt on particular system I usually compare complicated things like Java to a trivial C program that just allocates huge chunks of memory and see what successes or errors I get. ... - dave_thompson_085
... On further thought, rather than fighting with JVM and possibly OS issues, maybe you could just run multiple processes such as 5 processes each with 2000 threads, or 10 processes each with 1000, or whatever works? AIUI jmeter is very strongly parallel, that is, each thread does its own work independent of the other threads, so it they don't really need to be in the same process. You may need to set up several working directories and config files and so on instead of just one, but I would expect that shouldn't be too difficult. Good luck. - dave_thompson_085

2 Answers

0
votes

Make sure you are using a 64 bit jre environment the error should go away.

0
votes
  1. Make sure that your JVM heap tuning parameters are really applied. The best place to put them is locating the following line

    • for Windows: in jmeter.bat file

      set HEAP=-Xms512m -Xmx512m
      
    • for Linux/Unix/MacOSX: in jmeter file

      HEAP="-Xms512m -Xmx512m"
      

    and amending it according to your needs

  2. Make sure that you're running test in command-line non-GUI mode
  3. Make sure that you have all the Listeners disabled

See JMeter Performance and Tuning Tips for explanation on above and few more recommendations.

Actually the number of threads JMeter can kick off strongly dependent on what your test is doing, if it is something very "lignt" - it may be enough to use just one machine with 8Gb RAM, however if your test assumes massive postprocessing, sending, receiving and parsing large amounts of data, if you exhaust one machine resources and aren't able to reach the desired load - consider Remote Testing when one JMeter node orchestrates a number of slaves executing the same test scenario - it allows producing almost unlimited load.