Results 1 to 12 of 12

Thread: Tomcat heap memory issue -- where to solve?

  1. #1
    Registered Member
    Join Date
    Dec 2003
    Posts
    37

    Default Tomcat heap memory issue -- where to solve?

    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
    Last edited by alexheizer; 03-29-2006 at 01:26 AM.

  2. #2
    Secret Agent
    Guest

    Default

    I'm interested in knowing this as well

  3. #3
    Registered Member
    Join Date
    Dec 2003
    Posts
    37

    Default

    Quote Originally Posted by Secret Agent
    I'm interested in knowing this as well
    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. #4
    Registered User
    Join Date
    Nov 2005
    Posts
    1

    Default Not good solution

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

  5. #5
    Registered Member
    Join Date
    Dec 2003
    Posts
    37

    Default 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. #6
    Registered User
    Join Date
    Aug 2003
    Posts
    2

    Default

    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. #7
    Registered Member
    Join Date
    Jun 2003
    Location
    Bharat
    Posts
    261
    cPanel/WHM Access Level

    Root Administrator

    Default

    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

    "-Xms512m",
    "-Xmx512m",
    means?

    And is there any other better way so that TomCat does not increase server load.
    Vinayak Sharma
    Vinsar.Net - Quality WebHosting Services at Economical Price USA, & European Servers
    Book Your Domain with Confidence Reliable Domain Reseller Account

  8. #8
    Registered Member
    Join Date
    Feb 2006
    Posts
    5

    Default

    Quote Originally Posted by Vinsar
    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

    "-Xms512m",
    "-Xmx512m",

    means?

    And is there any other better way so that TomCat does not increase server load.
    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:off do not attempt to use shared class data
    -Xshare:auto use shared class data if possible (default)
    -Xshare:on 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. #9
    Registered Member
    Join Date
    Jun 2003
    Location
    Bharat
    Posts
    261
    cPanel/WHM Access Level

    Root Administrator

    Default

    Thnaks Michael

    I will look at those.

    Any more ways to tame TomCat?
    Vinayak Sharma
    Vinsar.Net - Quality WebHosting Services at Economical Price USA, & European Servers
    Book Your Domain with Confidence Reliable Domain Reseller Account

  10. #10
    Registered Member
    Join Date
    Sep 2002
    Posts
    20

    Default

    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. #11
    Registered Member
    Join Date
    May 2003
    Location
    Hokkaido, JAPAN
    Posts
    91

    Default 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. #12
    cPanel Staff cPanelTristan's Avatar
    Join Date
    Oct 2010
    Location
    somewhere over the rainbow
    Posts
    7,610
    cPanel/WHM Access Level

    Root Administrator

    Default Re: Tomcat heap memory issue -- where to solve?

    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.
    cPResources: Support Options | More Support Options | Forums Search | cPanel.net Site Search | Mailing Lists(Alt) | Docs
    -- Tristan, Technical Analyst III, Forums Specialist, cPanel Tech Support

    Submit a ticket | Check an existing ticket

Similar Threads

  1. Tomcat Memory and Disk Allocaiton, Trying to help a user with Tomcat
    By bcvnbhjag in forum cPanel & WHM Discussions
    Replies: 0
    Last Post: 07-02-2011, 04:50 AM
  2. How to solve Horde login issue?
    By its_fine in forum E-mail Discussions
    Replies: 9
    Last Post: 08-12-2010, 12:22 AM
  3. How to solve Horde login issue?
    By its_fine in forum New User Questions
    Replies: 6
    Last Post: 10-19-2009, 02:31 AM
  4. Please solve this issue
    By rajuru in forum cPanel & WHM Discussions
    Replies: 6
    Last Post: 03-05-2008, 05:57 PM
  5. Tomcat and Memory
    By dgbaker in forum cPanel & WHM Discussions
    Replies: 13
    Last Post: 01-07-2005, 05:05 PM
bargain