90

I am working with tomcat 6.0, and while I am indexing (not while i am starting tomcat), I have a permgen space error.
How could I increase that space??

Thanks

bluish
  • 26,356
  • 27
  • 122
  • 180
Blanca
  • 957
  • 2
  • 8
  • 10
  • I checkes similar question before, but don't help me. Where is -XX:NewSize=2.125m going? – Blanca Jun 09 '10 at 07:55
  • possible duplicate of [Dealing with "java.lang.OutOfMemoryError: PermGen space" error](http://stackoverflow.com/questions/88235/dealing-with-java-lang-outofmemoryerror-permgen-space-error) – Raedwald Aug 13 '14 at 12:00

5 Answers5

143

You can use :

-XX:MaxPermSize=128m

to increase the space. But this usually only postpones the inevitable.

You can also enable the PermGen to be garbage collected

-XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled

Usually this occurs when doing lots of redeploys. I am surprised you have it using something like indexing. Use virtualvm or jconsole to monitor the Perm gen space and check it levels off after warming up the indexing.

Maybe you should consider changing to another JVM like the IBM JVM. It does not have a Permanent Generation and is immune to this issue.

Peter Tillemans
  • 34,983
  • 11
  • 83
  • 114
  • Thanks!! But where must I write it down?? I guess in one flile here: tomcat/conf Am I wrong?? – Blanca Jun 09 '10 at 08:05
  • 1
    For tomcat you can create an environment variable CATALINA_OPTS with as value these options concatenated. The startup script will add these to the Java commandline before starting tomcat. This cannot be done from tomcat configuration as the JVM is already configured at that point. – Peter Tillemans Jun 09 '10 at 08:34
  • 2
    If it's FreeBSD, add the options to the /etc/rc.conf file. First read the tomcat start script to see the exact parameter it'll be looking for. – Brian Knoblauch Oct 08 '12 at 14:20
  • 3
    In OpenJDK 7 CMSPermGenSweepingEnabled is deprecated in favor of CMSClassUnloadingEnabled – Petr Gladkikh Jul 17 '14 at 02:27
13

For tomcat you can increase the permGem space by using

 -XX:MaxPermSize=128m

For this you need to create (if not already exists) a file named setenv.sh in tomcat/bin folder and include following line in it

   export JAVA_OPTS="-XX:MaxPermSize=128m"

Reference : http://wiki.razuna.com/display/ecp/Adjusting+Memory+Settings+for+Tomcat

Paroksh Saxena
  • 213
  • 4
  • 7
3

You can also increase it via the VM arguments in your IDE. In my case, I am using Tomcat v7.0 which is running on Eclipse. To do this, double click on your server (Tomcat v7.0). Click the 'Open launch configuration' link. Go to the 'Arguments' tab. Add -XX:MaxPermSize=512m to the VM arguments list. Click 'Apply' and then 'OK'. Restart your server.

gallea01
  • 82
  • 1
  • 8
3

if you found out that the memory settings were not being used and in order to change the memory settings, I used the tomcat7w or tomcat8w in the \bin folder.Then the following should pop up:

tomcat monitor

Click the Java tab and add the arguments.restart tomcat

Kevin STS
  • 183
  • 2
  • 10
0

On Debian-like distributions you set that in /etc/default/tomcat[67]

der_do
  • 21
  • 4