1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Tomcat heap memory issue -- where to solve?

Discussion in 'General Discussion' started by alexheizer, Mar 28, 2006.

  1. alexheizer

    alexheizer Member

    Joined:
    Dec 17, 2003
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    I installed Tomcat through WHM and am receiving heap memory issues. I did a search in the forums for a resolution and only found responses like "increase the memory to the JVM" and even "if you don't know how to maintain Tomcat, don't use it". My problem is this:

    I know how to increase the memory for the JVM in several different ways, but nothing seems to work. On other systems there's a server.sh or other file that CATALINA_OPTS or JAVA_OPTS can be placed so that -Xmx and -Xms options are actually accepted and used by Tomcat. I placed the opts into both the startup.sh and catalina.sh files, but nothing changed. Also setting the environment variable for CATALINA_OPTS and/or JAVA_OPTS from the command line don't work either.

    Has anyone been able to get the heap memory changed for Tomcat?

    Server:
    AMD Athlon MP 2600
    1GB RAM
    one Tomcat/Java host/site
    RedHat Fedora2 Linux

    Thanks,
    Alex
     
    #1 alexheizer, Mar 28, 2006
    Last edited: Mar 29, 2006
  2. Secret Agent

    Secret Agent Guest

    I'm interested in knowing this as well
     
  3. alexheizer

    alexheizer Member

    Joined:
    Dec 17, 2003
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    I found a solution for my own situation. Make sure fork bomb protection is disabled in WHM, and then in your /etc/profile and /etc/bashrc files make sure to comment out any ulimit values. This allows the tomcat user to run without memory limits.

    Not sure what to do for shared hosting environments to limit ordinary users' memory usage, but this works fine on a server that doesn't need to be locked down so much.

    Alex
     
  4. kgecici

    kgecici New Member

    Joined:
    Nov 2, 2005
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Not good solution

    This solution couses major security problem. I need to use "Xms" "Xmx" options. but where?
     
  5. alexheizer

    alexheizer Member

    Joined:
    Dec 17, 2003
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    Insecure or not working at all

    Well I am the only user on this server so, I need it to do what I need it to do. Since nobody knows how to get Tomcat to run with the Xms and Xmx switches on a cPanel version so that it actually listens to CATALINA_OPTS and JAVA_OPTS switches in the catalina.sh file, or isn't able to educate the rest of us, insecure it is for me.

    Good luck! :)
    Alex
     
  6. jklassen

    jklassen New Member

    Joined:
    Aug 5, 2003
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    I've been looking for the solution to this also.

    It appears that the tomcat service is handled via /usr/sbin/starttomcat AND /usr/sbin/stoptomcat.

    Open /usr/sbin/starttomcat and look for the following:

    system("./jsvc",
    "-user","tomcat",
    "-Xms512m",
    "-Xmx512m",
    "-cp","./bootstrap.jar",
    "-Djava.endorsed.dirs=../common/endorsed",
    "-debug","-outfile","../logs/catalina.out",
    "-errfile","../logs/catalina.err","-verbose",
    "org.apache.catalina.startup.Bootstrap","-security",
    "$options");

    Add the -Xms and/or -Xmx options into the java service options list (as above). This appears to do it for my system.

    Jeff
     
  7. Vinayak

    Vinayak Member

    Joined:
    Jun 27, 2003
    Messages:
    259
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Bharat
    This TomCat memory issue is bugging me too on several cPanel servers.

    I tried the above solution but then TomCat wouldn't start at all.

    Can some one clear what does

    means?

    And is there any other better way so that TomCat does not increase server load.
     
  8. mpeacock

    mpeacock New Member

    Joined:
    Feb 1, 2006
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    You can get help on the X commands from your command line:

    /home/testuser> java -X
    -Xmixed mixed mode execution (default)
    -Xint interpreted mode execution only
    -Xbootclasspath:<directories and zip/jar files separated by ;>
    set search path for bootstrap classes and resources
    -Xbootclasspath/a:<directories and zip/jar files separated by ;>
    append to end of bootstrap class path
    -Xbootclasspath/p:<directories and zip/jar files separated by ;>
    prepend in front of bootstrap class path
    -Xnoclassgc disable class garbage collection
    -Xincgc enable incremental garbage collection
    -Xloggc:<file> log GC status to a file with time stamps
    -Xbatch disable background compilation
    -Xms<size> set initial Java heap size
    -Xmx<size> set maximum Java heap size

    -Xss<size> set java thread stack size
    -Xprof output cpu profiling data
    -Xfuture enable strictest checks, anticipating future default
    -Xrs reduce use of OS signals by Java/VM (see documentation)
    -Xcheck:jni perform additional checks for JNI functions
    -Xshare:eek:ff do not attempt to use shared class data
    -Xshare:auto use shared class data if possible (default)
    -Xshare:eek:n require using shared class data, otherwise fail.

    The -X options are non-standard and subject to change without notice.



    Most java server environments are pretty memory intensive as all objects get created in the java heap space. If you're running out of heap, there are a bunch of places you can look. For Tomcat, check the memory faq

    In general, though - if you set the either the initial heap size (-Xms) or the max heap (-Xmx) to some value greater than the available memory on your server, you're probably simply running out of RAM. Check your tomcat error log - there's probably an OutOfMemory Error during start up.

    Cheers, Michael
     
  9. Vinayak

    Vinayak Member

    Joined:
    Jun 27, 2003
    Messages:
    259
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Bharat
    Thnaks Michael

    I will look at those.

    Any more ways to tame TomCat?
     
  10. flipper

    flipper New Member

    Joined:
    Sep 14, 2002
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    In case anyone comes across this thread looking for how to change memory for tomcat, now you just need to edit /var/cpanel/tomcat.options to set options for tomcat memory usage.
     
  11. asiams

    asiams Member

    Joined:
    May 28, 2003
    Messages:
    91
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Hokkaido, JAPAN
    tomcat.optoins location?

    Hello

    I could not find tomcat.options under /var/cpanel/.

    I tried locate tomcat.options, but it does not give me right location.

    Any suggestions?

    Thanks.
     
  12. cPanelTristan

    cPanelTristan Active Member
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,621
    Likes Received:
    4
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    I realize this post is older, but I want to reply to it due to information I've determined recently that I wanted to share in case anyone else runs into this thread.

    The /var/cpanel/tomcat.options file does not exist by default. It would need to be created and then the startup options needed placed into that file. The options must have a - in front of them. Let's say you would like to limit the following:

    Code:
    -Xmx200M
    -Xms100M
    the "-Xms<size>" initial Java heap size for the application to 100MB, and the "-Xmx<size>" maximum Java heap size to 200MB. If the - is not placed in front of the option when putting the values into /var/cpanel/tomcat.options file that is created, then Tomcat will refuse to startup properly.

    This method would be preferred over directly editing /usr/sbin/starttomcat as we would revise that file upon Tomcat updates. The /var/cpanel/tomcat.options file would not be edited by our scripts or upon updates.
     

Share This Page