jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sonam Chauhan <son...@gmail.com>
Subject “cannot create native thread” error and memory usage
Date Mon, 28 Mar 2011 01:57:12 GMT
Hello JMeter users: Just wanted some feedback on a formula for max. active
threads and some thoughts on errors when running tests with lots of threads.



Someone recently asked a question about JMeter running out of memory when
creating new threads (the “cannot create native thread” error).



I came up with this formula for maximum active threads in a thread group
with a simple ramp



*maximum active threads* = average thread lifetime * total threads/ramp
period


Does this look right? The way I understand the formula is it finds the total
threads created by the time the first threads start terminating. Since
threads now terminate at the same rate they are being added by the ramp,
this is a steady-state figure - the “high water mark” of active threads.



As for memory usage, each thread uses heap memory and stack memory. Total
heap memory usage limits are defined in the JMeter run script by the ‘Xms’
(min.) and ‘Xmx’ (max.) flags. Stack memory usage is a fixed memory
allocation per thread -- it can be changed by the ‘Xss’ parameter (but its
best left alone in my experience)



A 32-bit JVM running on  a 32-bit OS can occupy 2 GB of RAM at most. As some
RAM is taken up by the JVM runtime itself, a JMeter instance can really
access only 1.5 -1.7 GB of RAM – the sum of both the heap and stack usage
fit into this.  So we do need to be careful about allocating too much heap.
Lets assume *Xms* is set to *1.5 GB *and the test has a high water mark of
500 active threads. The JVM will  probably run out of memory creating
threads… even though there could be plenty of heap left unused, 500 threads
require about 180 MB of stack (for a 32 bit JVM), and this will cause the
 test to  probably generate a “cannot create native thread” error at some
point.


Regards

Sonam

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message