• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Unable to change permgen memory

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi!!

We have a PermGen Out of memory exception in our J2EE web application:

java.lang.OutOfMemoryError: PermGen space

We have read so many posts about how to solve it and almost all of them say that we have to increase PermSize (default and maximum). But we are not able to change them. We have tried to modify setenv.sh, catalina.sh and startup.sh adding this code:

export JAVA_OPTS="-XX:PermSize=M -XX:MaxPermSize=1024m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled"

And we also try to do it using the terminal:

export JVM_ARGS="-XX:PermSize=256m-XX:MaxPermSize=1024m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled"

But when we check it using "jstat -gcpermcapacity " nothing changes; the memory is always the same. Our enviroment is Centos 6, Apache 2.2, Tomcat 5.5, Java 6 and we have done our app deploy installing servlets by WHM in our account.

Thank you very much!
 
Saloon Keeper
Posts: 24283
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Diego!

Here's one I'm using successfully. It's in my setenv.sh file:

The JVM in question is a Sun Java 6 JDK.
 
Diego Munch
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you!
How can I check if this configuration is being applied? Is there any command to know how much PermGen memory is the maximum? We have tried "ps ax | grep tomcat" and "jstat -gcpermcapacity <PID>". The last one allways shows the same value for PGCMX(maximum memory): 83968.0, so we think that none of our configurations have been succesful.
Our server run Tomcat through WHM and cPanel. We use an account function to install servlets and when we change something in our webapp we use the "restart Tomcat" option in WHM (which is a webhost manager, a cPanel's layer), so we don't know the exactly script which run Tomcat, that's the reason (we think) becouse our attempts failed.
 
Tim Holloway
Saloon Keeper
Posts: 24283
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, the way I knew it worked was that Tomcat stopped throwing PermGenSpace errors!

I noticed that you were attempting to set PermGenSpace to a very large value. PermGenSpace is a separate memory space from Heap/Stack space and it doesn't need to be that large. Just larger than the default in cases like ours. I was using memory-statistics to determine requirements:


ps shows the memory usage for the entire VM, of which PermGenSpace is just a subset. I can't vouch for what WHM does, although hopefully it isn't so far off-track that it doesn't honor setenv.sh. If you can, try jprofiler. I believe that it can display PermGenSpace in real time graphically.
 
Diego Munch
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have using smaller values but the problem is the same. We don´t know if our modifications in the configutation files (setenv.sh or startup.sh or catalina.sh) have been applied.
 
Diego Munch
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
¡We have solved the problem!
Our application runs on WHM, and the script that runs the restart of Tomcat does not use the startup.sh file. In our case, the reset is performed by "starttomcat", a file found in /usr/bin. We have modified the file, leaving the variable my @ cmd as follows:

my @cmd = (

"./jsvc",
"-user",
"$user",
"-XX:PermSize=64M",
"-XX:MaxPermSize=512m",
"-cp",
"$jars",
"-Djava.endorsed.dirs=../common/endorsed",
"-outfile",
"${logdir}/catalina.out",
"-errfile",
"${logdir}/catalina.err",
"-verbose",
@options,
"org.apache.catalina.startup.Bootstrap",
#"-security",
"start",
);


¡It runs!
 
Diego Munch
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow! Without "¡", of course!
 
Tim Holloway
Saloon Keeper
Posts: 24283
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
¡Stellar!

Keep an eye on WHM, though. That particular configuration is for Tomcat 5. It works (for the moment) on Tomcat 6, but ¿quien sabe? on Tomcat 7.
reply
    Bookmark Topic Watch Topic
  • New Topic