On a Redhat CentOS 6.4 are only a few process running, using about 3GB RAM (System has 12GB available). One of the processes is a WSO2ESB Server (java), we start it with those parameters:

 -Xms2048m -Xmx3072m

After a while we get an OutOfMemory Exception, but the java process(WSO2ESB) process is not even using its 3GB. In the jconsole you can also see that those parameters where set correctly (Linux Server has about 9GB free RAM at this point)

Does Linux not give us the configured 3 GByte RAM?

On a exactly same Windows Installation - the java process can use it's 3GB Ram without any issue.

enter image description here Screenshot of the jconsole showing the heap memory usage only between 0.3 and 1.0 GB. At moment of OutOfMemory exception Heap memory was at 0.5GB, but the process would have 3GB to work with, but it doesn't...

EDIT: added log of java process:

java.lang.OutOfMemoryError: unable to create new native thread

EDIT2: added free -m output: enter image description here

  • In the /var/log/messages file, you will see OOM killer messages where you can search by the string 'Out of memory'. I would request you to put unsnipped logs pertaining to the OOM messages in the question. – Soham Chakraborty Nov 25 '14 at 14:23
  • Look at the little green bar chart on the right, one area of your heap is certainly out of memory and it is likely permgen as Jakov says. The graph you have in your screenshot is very basic. Try using jvisualvm (also in the JDK) with the visual GC plugin: profiler.netbeans.org/blog/images/visualgc_2.png it's easily installable from within visualvm and gives a lot more info than jconsole. – Mike Nov 25 '14 at 16:44
  • @SohamChakraborty in the file /var/log/messages i can not find any 'OOM' or 'Out of memory' entrys. Strange thing is that the file has only entrys from yesterday. Non form the crash today – Darkpara Nov 25 '14 at 16:46
  • Can you provide us with the "free" command output from the Linux? – trikelef Nov 25 '14 at 21:25
  • @trikelef i added the screenshot of free -m to the post. – Darkpara Nov 26 '14 at 7:02

I solved the problem. wso2esb was using over 1000 Threads. But on linux the default amout of Threads a user can use is set to 1024. I had to rise the limit for my user, now everything works fine.

To do so: open /etc/security/limits.conf and add following two lines for your user:

myuser             soft    nproc           8192
myuser             hard    nproc           8192

enter image description here


Java has multiple generations of heap space, new, old permanent generation.

If you set really high Xmx, that's used for heap, and even if you don't use whole heap, you can run out of memory. This usually happens if you run out of PermGen space.

Permanent generation of heap is used to store String pool and various Meta data required by JVM related to Class, method and other java primitives. Perm space is usually 64MB, so if you have lot of classes or huge strings you can run out of it.

Try increasing permgen size by adding:


to your java startup options.

  • Hi, we had already 256M. So I tried 512M and 1024M, and I got same error again. – Darkpara Nov 25 '14 at 16:35

whats your Data Segment Size for the heap -Xms2048m -Xmx3072m.

your Data Segment Size should be corresponding to your maximum heap size( which is 3072m in this case). So your data segment size should be set to atleast 3221225472 ( in Bytes 3*1024*1024*1024 = 3GB)

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.