[jcifs] OutOfMemoryError unable to create new native thread
peter_zavadsky at symantec.com
Fri Mar 5 11:11:36 MST 2010
This has been already here. However, I think I might have found the culprit.
Here is a test case, which reproduces the issue (at least on my machine). My
configuration: Windows Server 2008 R2 64 bit, Java 1.6.0_05 (32 bit!), JCIFS
It seems that when there are a lot of consecutive requests, the previous
QueryThread instances don't die out, therefore the number of the threads
increases until it reaches the limit of the process resources (on my machine
it is ~1900 threads).
Note you can try to workaround this problem by increasing
I tried one fix, i.e. to use join method on the QueryThreads in the
lookupServerOrWorkgroup method. That fixes the problem, however it also degrades
the performance terribly.
A better fix is needed.
It seems that the problem is that there are created new QueryThreads per each
request, which consumes a lot of resources. Much better would be to reuse the
dedicated QueryTheads as queues.
public class UniAddressTest
public void testLookup() throws UnknownHostException
for (int i = 0; i < 10000; i++)
NbtAddress nbtAddress =
private static void dumpThreads(Throwable e)
Map<Thread, StackTraceElement> allStackTraces =
System.err.println("***Dumping threads on***");
System.err.printf("Total number of threads=%d%n",
for (Thread t : allStackTraces.keySet())
System.err.printf("%n%s-%s%n", t, t.getState());
for (StackTraceElement se : allStackTraces.get(t))
More information about the jCIFS