I'm seeing a strange java.lang.OutOfMemoryError error (partial stack trace below). The thing is that the java process does not crash. I see this error in the logs but the process seems to stall but does not exit.
Thanks.
Exception in thread "main" java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:691)
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:943)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1325)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:132)
at com.amazonaws.services.s3.transfer.internal.UploadMonitor.<init>(UploadMonitor.java:126)
at com.amazonaws.services.s3.transfer.TransferManager.upload(TransferManager.java:384)
at com.amazonaws.services.s3.transfer.TransferManager.upload(TransferManager.java:344)
at com.amazonaws.services.s3.transfer.TransferManager.upload(TransferManager.java:272)
java.lang.OutOfMemoryError: unable to create new native thread
This is due to the fact that no more native threads could be created from your app.
Check the number of Threads your app is spawning. Most likely this is the culprit.
You can take a Thread dump for analyzing this.
Then check your stack size. Xss param will give you that. Try tweaking it.
Increasing Xmx won't help you here. In fact on 32 bit JVMs it will exacerbate the issue.
The reason why your process is not stopping is because of the fact that Uncaught Exceptions only terminate their own thread, not the entire application as mentioned by Jan in the comments.
An OutOfMemoryError, or any Error for that matter, does not make the JVM crash. It might make it exit if you only have one Thread where you don't catch Errors (not very useful anyway), for example. If the JVM doesn't exit, it will be in a unstable state anyway, and should be restarted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With