1

Recently Our production server: tomcat6 is getting hung frequently and throwing following error "java.lang.OutOfMemoryError: PermGen space", which is running windows 2003 server with 4GB of RAM. 25 application are running on that server,looks like its been overloaded but, it was working fine previously. I tried cleaning up memory leaks like closing DB connections, increasing Heap memory with JAVA_OPTS. Still i could not find the exact root cause. Also Our Tomcat6 was not configured with manager application, therefore I could not run memory/health checks. Please guide me to resolve this.

Vic
  • 71
  • 1
  • 2
  • 9
  • 1
    PermGen is most commonly associated with class definitions (and with certain older xml parsers, IIRC). You might want to explicitly allocate more PermGen space since you're running 25 different applications (probably each with slightly different versions of the various supporting libraries). See http://stackoverflow.com/questions/3003855/increase-permgen-space – Gus Jan 13 '17 at 21:50

1 Answers1

1

You must increase the PermGen space editing your JAVA_OPTS and using the option XX:MaxPermSize (e.g., -XX:MaxPermSize=1024m). Increasing the heap size (Xmx) is not useful in your case.

I also suggest the use of a monitoring tool (APM) like Glowroot to investigate the memory usage and adjust your JAVA_OPTS as needed.

For more information about the purpose of the PermGen space and its garbage collection mechanism, look at this answer: https://stackoverflow.com/a/5387423/3260495

Community
  • 1
  • 1
Robert Hume
  • 1,129
  • 2
  • 14
  • 25
  • 1
    Thanks @Robert Hume, but i already added MaxPermSize in JAVA_OPTS with following set "JAVA_OPTS=%JAVA_OPTS% -Xms1024m -Xmx1024m -XX:MaxPermSize=1024m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -server". But still having the issue,Is there anyway to track whether tomcat instance pick that MaxPermSize or not? APM would good idea, i will try on that – Vic Jan 17 '17 at 13:52
  • Considering that you don't have the Tomcat Manager, you can add the `-XX:+PrintCommandLineFlags` argument to `JAVA_OPTS`, restart the server and then check the `logs/catalina.out` file: you should see one line containing all the command line flags you specified with `JAVA_OPTS`. – Robert Hume Jan 17 '17 at 13:53
  • 1
    Thanks @Robert Hume, even after adding PrintCommandLine argument to `JAVA_OPTS` also i am not getting details in logs. just an thought, for time being , is there any way to find whether the Tomcat is running or not ?, for example ping from different server and getting email alert if tomcat is not responding(like URL content monitor), at-least we can get immediate action while server get hung – Vic Jan 17 '17 at 19:12
  • I tried the `-XX:+PrintCommandLineFlags` option and it works for me; try to issue `cat catalina.out |grep XX`. For your other question, please see http://stackoverflow.com/q/3944157/3260495 – Robert Hume Jan 17 '17 at 19:25