tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nikita Belov" <NBe...@abisoft.spb.ru>
Subject RE: JSP class loader
Date Tue, 25 Jul 2006 14:03:04 GMT
Chris,

>> I work on application which allows user to deploy/undeploy large 
>> number of the JSP pages to AppServer (JBoss 4.03sp1 + Tomcat 5.5). 
>> Standard Tomcat class loader caches classes for all deployed JSP 
>> internally and never clean its cache. This brings JVM to PermGen 
>> overflow error after several days of system work.
>
>Ouch. Are you saying that the sheer number of classes in your system 
>is overflowing your memory? 

Yes.

>That doesn't seem likely.
>
>After tomcat compiles your JSP, it loads the resulting class and
>executes it like a servlet.

I know.

>If you have an option enabled, it will detect updated JSPs, re-compile
>them, and reload them. It is certainly possible that when this happens,
>Tomcat discards the entire ClassLoader and starts fresh. In that case,
>if you have 10,000 JSPs, then each time you reload, you'll get 10,000
>more classes loaded into memory. If this happens enough times, you'll
>run out of memory since Java does not clean up old, unused classes in
>memory.

I have made some research. Looks like JVM unloads classes from PermGen, 
when classloader instance, used for loading these classes, is destroyed 
by GC. See program attached to the letter. It simply loads classes from
specified dir. This program is intended to be monitored by jconsole.

>Is this the behavior you are describing? 

Yes.

>If so, then you can't fix the
>problem by writing your own JSP compiler and/or ClassLoader. 

I guess loading each JSP class by separate classloader instance 
will fix the problem. Classloader will be created when HTTP request 
recived and no one reference on this classloader instance will be 
stored during request processing, so it can be destroyed by GC.

>Your best bet is not to modify your JSPs and have them re-loaded.
>
>Is this in a development setting or production? I would say that 
>having JSP reloading turned on in production is a mistake.

I am working on system for business processes processing. Each 
business process can be deployed and launched by user many times. 
Business process can contain JSP(JSF) pages, also it can contain 
Java-scriplets (POJO classes) with business logic. Each scriplet is 
loaded with separate classloader and therefore successfully unloaded 
from PermGen when classloader destroyed. All JSP classes are loaded 
by the one Tomcat classloader and can't be unloaded from memory. 
This is the problem.

Any ideas?

--
Nikita

Mime
View raw message