How do I properly set the permgen size?

188,535

Solution 1

You have to change the values in the CATALINA_OPTS option defined in the Tomcat Catalina start file. To increase the PermGen memory change the value of the MaxPermSize variable, otherwise change the value of the Xmx variable.

Linux & Mac OS: Open or create setenv.sh file placed in the "bin" directory. You have to apply the changes to this line:

export CATALINA_OPTS="$CATALINA_OPTS -server -Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m"

Windows:

Open or create the setenv.bat file placed in the "bin" directory:

set CATALINA_OPTS=-server -Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m

Solution 2

Don't put the environment configuration in catalina.bat/catalina.sh. Instead you should create a new file in CATALINA_BASE\bin\setenv.bat to keep your customizations separate of tomcat installation.

Solution 3

So you are doing the right thing concerning "-XX:MaxPermSize=512m": it is indeed the correct syntax. You could try to set these options directly to the Catalyna server files so they are used on server start.

Maybe this post will help you!

How to make sure that Tomcat6 reads CATALINA_OPTS on Windows?

Share:
188,535
황현정
Author by

황현정

Updated on February 24, 2020

Comments

  • 황현정
    황현정 about 4 years

    I have this VM with tomcat, java, and grails in it. I've been getting permgen errors so I looked around and found the solution:

    set JAVA_OPTS="-Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m"
    

    I use SSH to access the vm and type the arguments above. I suppose that would fix the problem. Thing is, I wanted to make sure that I did it correctly. So I searched again on how I could check the current permSize and this is the solution I got:

    jinfo -flag MaxPermSize 6444
    

    6444 is the pid, and as a response, I got this.

    -XX:MaxPermSize=85983232
    

    Question: Is the value of the maxPermSize in bytes? because, if it is, then that would mean that the java_opts command didn't work. I am expecting to get 512m but 85983232 bytes = 82 mb.. Or am I seeing it wrong..? Can anybody enlighten me on this? D:

  • 황현정
    황현정 almost 12 years
    I am using linux. But I'll read this and see how it works. thank you so much for replying. :3
  • Steve
    Steve almost 12 years
    Actually the advised way of setting this is by creating a setenv.bat (Windows) or setenv.sh (*nix) and putting the entries in there, Tomcat will pick these up and its easier to manage an upgrade
  • Mr. Lance E Sloan
    Mr. Lance E Sloan about 9 years
    I submitted an edit to add this to the accepted answer.
  • Jeremy
    Jeremy over 8 years
    There are a lot of answers similar to this around but I found that this was the clearest and simplest phrased, very helpful.
  • amdev
    amdev over 7 years
    Why change Xmx increase PermGen ?