I ran into this problem using the Maven Surefire plugin (v2.12). I had to configure surefire as follows:
<configuration> <forkMode>always</forkMode> ... other surefire config ... </configuration>
If I omitted the forkMode element in my configuration, I would get the error “it is impossible to create a new native thread”, because the java Surefire process would create thousands of threads otherwise, exceeding the limit of my OS (Mac OSX - you can see this in Monitor activity).
As far as I can tell, all new threads are created because the default forkMode is “once” in Surefire, and no matter what new threads are created, do not die until the “one” completed process is complete.
One final note: tuning my JVM memory seemed to have no effect (good or bad). Using standard values worked fine, as did the following:
<argLine>-Xss512k -Xms512m -Xmx4096m -XX:MaxPermSize=2048m</argLine>
source share