You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ondrej Zizka <xz...@stud.fit.vutbr.cz> on 2007/01/18 03:19:05 UTC

Tomcat PermGen OutOfMemoryException solution?

Hello,

I have the common problem with PermGen and Tomcat, see
http://mail-archives.apache.org/mod_mbox/tomcat-users/200606.mbox/%3C44858185.3040009@kerbtier.ch%3E

Suppose there is a school server where students (re)deploy their apps, each 
of which's classes definitions take about five to ten MB.
Now we have dozens of students, who will deploy at least once, but rather 
several times a day. That means the server has to be restarted every few 
hours.

There is no way to automatically flush the PermGen somehow? Or, under which 
conditions can the GC collect undeployed app's classes data?

Thanks, Ondra Zizka 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat PermGen OutOfMemoryException solution?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Christopher Schultz [mailto:chris@christopherschultz.net] 
> Subject: Re: Tomcat PermGen OutOfMemoryException solution?
> 
> > There is no way to automatically flush the PermGen somehow? 
> > Or, under which conditions can the GC collect undeployed
> > app's classes data?
> 
> I'm pretty sure you can't do that unless you write some JNI code,
> and you might not even be able to do it even then.

You can't.  Before an OOME is presented, the JVM has already cleaned out
the PermGen of any dead instances of java.lang.Class.

This is a pretty decent survey of several reasons why classes can't be
GC'd:
http://opensource.atlassian.com/confluence/spring/pages/viewpage.action?
pageId=2669

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat PermGen OutOfMemoryException solution?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ondrej,

Ondrej Zizka wrote:
> Suppose there is a school server where students (re)deploy their apps, each 
> of which's classes definitions take about five to ten MB.
> Now we have dozens of students, who will deploy at least once, but rather 
> several times a day. That means the server has to be restarted every few 
> hours.

I was recently taken to task for asserting that Java holds on to
outdated java.lang.Class objects even after the ClassLoader is
discarded. (This might happen when a webapp is reloaded).

It turns out that I'm an old war horse and that problem was fixed a very
long time ago.

If you are having memory problems it is more likely that one of the
following is occurring:

1. You have one or more misbehaving webapps (they are retaining memory
   longer than they should).
2. You are running a very old and/or buggy version of Java
   and/or Tomcat.
3. The webapp reload procedure is not working as you expect.
4. You have tons of libraries that are being individually reloaded
   by each web application. Take the advice of your article and
   provide shared versions of many popular libraries.

> There is no way to automatically flush the PermGen somehow? Or, under which 
> conditions can the GC collect undeployed app's classes data?

I'm pretty sure you can't do that unless you write some JNI code, and
you might not even be able to do it even then.

Another poster suggested that you have your students setup their own
Tomcat environments. I completely agree ;)

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFrwuj9CaO5/Lv0PARApS6AJ9a0NJROkyHw94AtRNMV7mHtravOgCfWCON
Jx0dBNtvOrY2aq/9v/CFBNI=
=j14Q
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat PermGen OutOfMemoryException solution?

Posted by Roger Keays <ro...@ninthavenue.com.au>.
Ondrej Zizka wrote:
> Hello,
> 
> I have the common problem with PermGen and Tomcat, see
> http://mail-archives.apache.org/mod_mbox/tomcat-users/200606.mbox/%3C44858185.3040009@kerbtier.ch%3E
> 
> Suppose there is a school server where students (re)deploy their apps, each 
> of which's classes definitions take about five to ten MB.
> Now we have dozens of students, who will deploy at least once, but rather 
> several times a day. That means the server has to be restarted every few 
> hours.
> 
> There is no way to automatically flush the PermGen somehow? Or, under which 
> conditions can the GC collect undeployed app's classes data?

How about having them each install their own Tomcat locally? It'd be 
part of the learning experience :)


> 
> Thanks, Ondra Zizka 
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


-- 
----------------------------------------
Ninth Avenue Software
p: +61 7 3137 1351 (UTC +10)
f: +61 7 3102 9141
w: http://www.ninthavenue.com.au
e: info@ninthavenue.com.au
----------------------------------------


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org