How to make sure that Tomcat6 reads CATALINA_OPTS on Windows?

后端 未结 4 1123
被撕碎了的回忆
被撕碎了的回忆 2021-02-03 14:48

I have a Tomcat6 running on a Windows2003 machine. I deployed 2 Grails apps on this server and I soon noticed that everything was crashing sometime after the deploy with a class

相关标签:
4条回答
  • 2021-02-03 15:05

    Actual way to do it (in Catalina.bat),

    set "JAVA_OPTS=-Djava.awt.headless=true -server -Xms512m -Xmx2048m -XX:PermSize=512m -XX:MaxPermSize=1024m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled"
    

    add this line in such a position so that this JAVA_OPTS is transferred to any of _EXECJAVA command at the end of file (if-else nested). I personally write this line as first statement of this batch

    0 讨论(0)
  • 2021-02-03 15:14

    Look where you are setting it, use echo [statements] to troubleshoot, try setting it right before its passed to the VM, something like:

    set CATALINA_OPTS="-Xms1024m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=512m"
    _EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% 
    -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" 
    -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" 
    -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%
    

    Make sure you have the right EXEC_JAVA not sure which version of the .bat file you have, but probably several if statements.

    Also make sure these are valid arguments for your VM.

    You can check your max heap size within your java code, use:

    long heapMaxSize = Runtime.getRuntime().maxMemory();
    

    Just print it out, if its correct based on your settings, you have a bad memory leak, if its not, then tomcat is not picking it up.

    0 讨论(0)
  • 2021-02-03 15:22

    Thank you all! I finally solved the issue by adding:

    -XX:+CMSClassUnloadingEnabled
    -XX:+CMSPermGenSweepingEnabled
    -XX:+UseConcMarkSweepGC
    -XX:PermSize=128m
    -XX:MaxPermSize=512m 
    

    To the java options on tomcat6w.exe.

    Thanks!

    0 讨论(0)
  • 2021-02-03 15:30

    I actually set those as JAVA_OPTS for my JVM before starting the server

    JAVA_OPTS=-Djvmarg='-Xms1024m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=512m'
    
    0 讨论(0)
提交回复
热议问题