[SOLVED] java.lang.OutOfMemoryError: unable to create new native thread
|
|
---|---|
Hi All, Yesterday (28.05.2015) I set up a simple test to catch timeout exceptions in Java API (TangORB-9.0.1):
In the morning I have found out the computer on which this test was running almost completely unresponsive. No wonder – my client has created 6,8K live ReplyReceiverTimer (org.jacorb.orb.ReplyReceiver.Timer). And it seems that already killed threads are not really freed. So starting a jive for instance gives this:
Environment setup:
Just to share this experience. But if someone has any idea how to work around this or fix please let me know! Best regards, Igor. |
|
|
---|---|
Hi Igor, this sounds like a bug. What I don't understand is there were "only" 6.8k live threads. I would assume you made many more proxies. Does this means some are being garbage collected but not all or not fast enough? I vaguely remember that we tried or wanted to cache proxies to the same device in the same process. I presume this is not the case in the current code but would this help as a way of reducing the number of open connections and threads to the same device? Naive question - could one say this is a bug in your software for not reusing the same proxy? When do you need this use case? In the meantime I do not have a work around, sorry! Andy |
|
|
---|---|
Hi Andy, There is only one proxy created. Then I sequentially read an attribute from this proxy. Each read creates a special thread on jacORB level. This thread counts 3s (timeout) and if not notified within this time throws timeout exception. Apart from 6,8K live such threads there are tons of finished threads of the same type (I suspect they are not properly freed, so OS runs out of memory allocated for threads' stacks). Best regards, Igor |
|
|
---|---|
Hi Igor, this sounds even more serious than I thought. You are saying a simple read of an attribute from a Java client is causing a thread to be created which is not being freed all the time. Do you know how many times you read the attribute in the time you noticed 6.8k threads? If we say a call takes approximately 200 microseconds then in 12 hours then we would expect roughly 216 million reads in 12 hours. Does this compare with your measurements? Does this mean for every 30k synchronous calls you have a dangling thread? This must be visible in all Java client applications. I wonder if other Java programmers have noticed this? One solution is to use events instead of synchronous calls. Events generate much less traffic and do not use JacORB. Andy |
|
|
---|---|
Seems to be the same problem: http://www.jacorb.org/bugzilla/show_bug.cgi?id=632 No clear fix though… |
|
|
---|---|
I agree |
|
|
---|---|
Hi For your information I did a test during the night and I did not have a problem on new native thread after 75 millions read_attribute(). The bug about Jacorb mailing list talks about release 2.3 (2010). The last TangORB.jar is build with Jacorb-3.5. I am not sure this bug still exists. Cheers Pascal |
|
|
---|---|
Well it seems the problem is in Oracle's JVM for Linux. When I run the same test using
everything runs smoothly |
|
|
---|---|
Interesting and good news! |
|
|
---|---|
Just found a related discussion in jacORB mailing list: http://lists.spline.inf.fu-berlin.de/pipermail/jacorb-developer/2014-June/000498.html Qoute: I think there's couple things you could do. |