4

I have a memory problem with a Linux server (CentOS). It is a VM. Below is the context.

It has 70Gb of RAM. There are 2 tomcat running on it.

One tomcat is given a heap of 13Gb and the other one a heap of 20Gb.

The one with 20Gb has the JVM option -Xss160k set (to try to solve my problem).

These 2 tomcat can be using up to 48Gb of RAM (virt.)

Linux is going to use the 70Gb and there will be about 35Gb of cached memory. The swap is 1Gb and it uses pretty much none of it (8Mb).

Now the problem is that I get the following error from the tomcat every so often:

OutOfMemoryError: unable to create new native thread 

If I am not mistaken, this happens if the OS itself runs out of memory and is therefore unable to create new threads.

Now the question is: how is that possible when it has 35Gb of cached memory? Shouldn't it re-allocate it and use it as needed.

Is there maybe some kernel option I can set to avoid this? For example it could use up to 65Gb, cache 30Gb and keep 5Gb free.

    3 Answers 3

    2

    This may be a question of limits set with ulimit. As the user running tomcat, do

    ulimit -a 

    In the output, look for the line max user processes.

    max user processes (-u) 1024 

    Try raising that value, e.g. ulimit -u 4096, before starting tomcat.

    2
    • I will try it out but I don't think it is the problem. I have another server (solaris) which does the exact same job and max user processes is 1024 and I have no problem there.
      – ttux
      CommentedApr 15, 2013 at 14:29
    • Use ps -eLf |grep #^tomcatuser|wc-l to count the number of process (including threads)CommentedMar 16, 2015 at 6:20
    2

    I found out how to make sure I have X amount of RAM available:

    sysctl -w vm.min_free_kbytes=... 

    I don't know yet if that will solve my problem or if Jenny D answer will.

    1
    • So how was the issue fixed?
      – jlliagre
      CommentedSep 13, 2015 at 12:02
    1

    What is the value for Xms,Xmx,PermSize MaxPermSize in your Catalina file ? Normally, I have seen adjusting these parameters avoids the JVM OutofMemory Issues.

    1
    • If the OutOfMemory is due to PermGen or Heap Space then yes you are correct. That is not my case here.
      – ttux
      CommentedApr 18, 2013 at 7:41

    You must log in to answer this question.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.