0

I am on a linux Red Hat machine and am trying to run a shell script that initiates a java application. It ran just fine yesterday but today I am getting this error:

Error occurred during initialization of VM
java.lang.OutOfMemoryError: unable to create new native thread
    at java.lang.Thread.start0(Native Method)
    at java.lang.Thread.start(Thread.java:714)
    at java.lang.ref.Reference.<clinit>(Reference.java:162)

free -m

total       used       free     shared    buffers     cached
Mem:         15951      14754       1196         66        217       3208
-/+ buffers/cache:      11328       4622
Swap:        15999          0      15999

I've done a bunch of reading on this issue but I'm not sure how to solve it on my system. It seems to be a system resources issue. can anyone help?

4
  • Well, it appears that you're out of memory. Please edit your question and post the output of free -m.
    – EEAA
    Apr 12 '16 at 14:32
  • @EEAA Just did. memory seems fine.
    – user348617
    Apr 12 '16 at 14:34
  • Have you tried increasing the amount of RAM available to the JVM?
    – EEAA
    Apr 12 '16 at 14:34
  • @EEAA no but from the output of free -m it doesn't seem like I need to do that do I?
    – user348617
    Apr 12 '16 at 14:35
1

This is a difficult question for us to answer because we don't know what your program does. Bottom line though is that java.lang.OutOfMemoryError is often caused by either spikes in traffic on your app or a memory leak.

You should play around with the two java flags that specify the memory allocation pools for the Java Virtual Machine:-Xmx(maximum memory allocated) and -Xms (initial memory allocated)

Play around with the numbers and see what works. If you see the java.lang.OutOfMemoryError error, then just increase the memory numbers and restart your java process.

1

You're specifying -Xmx128m when instantiating the JVM. Try increasing that value.

17
  • What would be a good value to set that at?
    – user348617
    Apr 12 '16 at 14:36
  • There's no possible way for me to help you answer that. You'll need to experiment and see what is good for your application with your workload.
    – EEAA
    Apr 12 '16 at 14:37
  • And can I get rid of _JAVA_OPTIONS all together?
    – user348617
    Apr 12 '16 at 14:37
  • That's quite unlikely. And why would you want to do so?
    – EEAA
    Apr 12 '16 at 14:38
  • What does the app do? Does it connect to a database and fetch work to do. Maybe change it to 256 and see if it starts. It's possible it's bringing back too much to store in memory.
    – davey
    Apr 12 '16 at 14:38
0

check max open files set for the user. You may need to increase that. use pidstat for the rpocessid (pidstat -h -r -u -p $javapid | grep -v "Command") and no of processes running (ps aux | grep 'java ' | grep "application name" | grep -v grep | wc -l). MUP (Max user process) set for the user is important.

2
  • If the open files limit was reached, there would be a different exception/error thrown, not an OutOfMemoryError.
    – Castaglia
    Apr 21 '16 at 0:18
  • OOM: unable to create new native thread is for MUP setting issue. This is nothing to do with Heap space. I have faced this issue in our application ans sorted by setting right MUP
    – Niks
    May 5 '16 at 5:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.