Results 1 to 6 of 6

Thread: JAVA_OPTS...

  1. #1

    Default JAVA_OPTS...

    I am trying to increase the memory for my JVM heap and permgen on my Tomcat 6 server. I was getting out of memory errors whenever I tried to run a second webapp. I am very new at this, but to my understanding the method is to put your JVM startup switch settings in the JAVA_OPTS variable. This is my switch:
    Code:
    JAVA_OPTS="-Xms128m -Xmx512m -XX:MaxPermSize=512m"
    I put this it /etc/bash.bashrc. On startup I still get
    Code:
    ...
    java.lang.OutOfMemoryError: PermGen space
    ...
    java.lang.OutOfMemoryError: PermGen space
    ...
    These webapps both run fine on their own in Tomcat, but not together.

    So my questions are:

    1) Is my JAVA_OPTS in the correct place?
    2) How can I tell how much memory the JVM is actually using?

    Would appreciate any ideas!

  2. #2
    someone316 NNTP User

    Default Re: JAVA_OPTS...

    Go to the bin directory where tomcat is installed and do the following:

    1. cp catalina.sh catalina.sh-today's-date

    Add number 2 in your catalina.sh

    2. CATALINA_OPTS="-Xms128m -Xmx128m"

    3. bounce tomcat

    // Note: assuming your local machine is running
    Tomcat on port 8080
    4. http://localhost:8080/manager/status


    Regards,
    Someone316

  3. #3
    Join Date
    Jun 2008
    Location
    Amor, Leiria, Portugal
    Posts
    55

    Default Re: JAVA_OPTS...

    Quote Originally Posted by someone316 View Post
    Add number 2 in your catalina.sh

    2. CATALINA_OPTS="-Xms128m -Xmx128m"
    Although that works, it's a dirty shortcut :-).

    Your change to /etc/bash.bashrc should work if you add
    Code:
    export CATALINA_OPTS="..."
    Without "export" the variable will not be visible. If you, or any other user, are starting/stopping tomcat then ~/.bashrc is a better place in my opinion.

    Just one more note, you can "quickly" test a setup by running tomcat with the command
    Code:
    $> CATALINA_OPTS="-Xms128m -Xmx512m -XX:MaxPermSize=512m" catalina.sh run
    or
    Code:
    $> export CATALINA_OPTS="-Xms128m -Xmx512m -XX:MaxPermSize=512m"
    $> catalina.sh run

  4. #4
    someone316 NNTP User

    Default Re: JAVA_OPTS...

    Quote Originally Posted by m4ktub View Post
    Although that works, it's a dirty shortcut :-).
    Really, please explain? How would this work with multiple tomcat instances running on the same host with different CATALINA_OPTS? Making the changes in catalina.sh seems valid, this way you isolate it to the given tomcat instance.

    Regards,
    Someone316

  5. #5
    Join Date
    Jun 2008
    Location
    Amor, Leiria, Portugal
    Posts
    55

    Default Re: JAVA_OPTS...

    Quote Originally Posted by someone316 View Post
    Really, please explain?
    Its just my general policy of not customizing installed files.

    Anyway, tomcat provides many options to override settings without editing the default files. Look for the CATALINA_BASE property. It allows you to have a single installation and multiple configurations (server.xml, webapps, etc).

    Code:
    $> CATALINA_BASE="path1" CATALINA_OPTS="-Xmx128m" CATALINA_PID="instance1.pid" catalina.sh start
    $> CATALINA_BASE="path2" CATALINA_OPTS="-Ddebug ..." CATALINA_PID="instance2.pid" catalina.sh start

  6. #6

    Default Re: JAVA_OPTS...

    Thanks for the responses, guys! Will post later...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •