How do I properly set the permgen size?

JavaTomcatGrailsJvmPermgen

Java Problem Overview


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:

Java Solutions


Solution 1 - Java

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 - Java

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 - Java

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!

https://stackoverflow.com/questions/3583757/how-to-make-sure-that-tomcat6-reads-catalina-opts-on-windows

Solution 4 - Java

Completely removed from java 8 +
Partially removed from java 7 (interned Strings for example)
source

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Question황현정View Question on Stackoverflow
Solution 1 - JavaamicnghView Answer on Stackoverflow
Solution 2 - JavamatabaresView Answer on Stackoverflow
Solution 3 - JavaLoic O.View Answer on Stackoverflow
Solution 4 - JavaMikeView Answer on Stackoverflow