4

I keep running into OOM errors and subsequent JBoss crashes, even though the heap shows that all of the memory allocated to it isn't used up.

For eg: If I have 1200MB allocated as the heap size (Xmx), crashes occur well below that limit with none of the individual generations in the heap (young / old / perm) at a 100%.

The box has plenty of RAM. Why might java be reporting this error when its really not out of memory?

 Heap

 PSYoungGen      total 67456K, used 9525K [0x57540000, 0x5c170000, 0x5fa90000)
  eden space 66432K, 12% used [0x57540000,0x57d91520,0x5b620000)
  from space 1024K, 98% used [0x5c070000,0x5c16c198,0x5c170000)
  to   space 3008K, 0% used [0x5bb90000,0x5bb90000,0x5be80000)

 PSOldGen        total 466048K, used 313530K [0x14a90000, 0x311b0000, 0x57540000)
  object space 466048K, 67% used [0x14a90000,0x27cbea38,0x311b0000)

 PSPermGen       total 226432K, used 141461K [0x04a90000, 0x127b0000, 0x14a90000)
  object space 226432K, 62% used [0x04a90000,0x0d4b55e8,0x127b0000)
2
  • The message is - OOM - Unable to create a new thread Commented Jan 25, 2012 at 23:15
  • 6
    You should edit your post above and paste the actual and complete error message that you have received. Commented Jan 25, 2012 at 23:16

2 Answers 2

3

Yes it is possible to get an OOME when you've still got plenty of free heap space.

When you create a thread the JVM needs to allocate memory for the thread's stack. However the JVM doesn't allocate the thread stack in the heap. (The thread stack needs to be in memory that won't be moved by the garbage collector.) Instead, it requests it directly from the OS. If the OS can't satisfy that request, you get an OOME ... irrespective of your heap size.

Apparently, an OOME can also occur during thread creation if your application exceeds the operating system's per-process thread limit. (On Linux / Unix this is controlled by ulimit -u ...)


It is a bit difficult to say what is happening in your case. I suspect that your application is simply trying to create too many threads and running into one of the limitations above. You could try reducing the thread stack size, but a better approach would be to figure out why you are creating so many threads and stop it. (Huge numbers of threads tend to waste resources ... and make your application slower in various ways.)

Sign up to request clarification or add additional context in comments.

Comments

2

Have a look at this answer on the JBoss community site as to why you'd get the Unable to create a new thread OOM

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.