You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Julian Löffelhardt <ju...@austria.fm> on 2002/12/30 20:37:10 UTC

reducing tomcat & jasper memory footprint

Hi,

I'm using Apache 1.3.26 and 3 tomcat 4.0.4 instances with AJP13 & loadbalancing .
Our application is a CMS where all the published articles are generated offline as JSP-Files, one jsp per article.

We had hige problems with the memory footprint. Due to the fact that every jsp is generated as a class and there are about 200 new artices per day the permanent segment of the JVM heap gets filled with all the classes, and I get an OutOfMemoryError.
My workaround for now is setting -XX:PermSize and --XX:MapPermSize to higher values, but this just delays application hang-up.

With 64 megs of permSize our Server had an approx. uptime of 1 day now it's about 3-4 days.

Is there any way to unload jsp-Files (unload the class) ?

llap,
julian



Re: reducing tomcat & jasper memory footprint

Posted by "Jerome Lacoste (Frisurf)" <la...@frisurf.no>.
On Tue, 2002-12-31 at 01:55, Julian Löffelhardt wrote:
> Hi,
> 
> My problem isin't javac memory leakes. Due to the apache/tomcat
> documentation I was  aware of this an setup jikes as my jsp compiler. I'm
> also using JDK 1.4.1 so the javac issues should be solved, nonetheless.
> The main problem is as follows:
> 1. Every article & every page in general is a jsp page
> 2. All the pages are generated by a legacy CMS-System (imperia) and I can't
> change the structure of it's works.
> 3. Every jsp page, once loaded, consumes memory, since the class remains
> loaded.
> 4. We have 1000s of pages , every day some 200-300 new, so memory use
> increases.
> 
> Conclusion:
> The way we use jsp's for a cms is faulty. But I can't do anything about
> this.
> Increasing permSize of the JVM helps a lot. Maybe it would be a good idea to
> include some hints about -XX:MaxPermSize and XX:PermSize into the
> documentation because it really helps lessen the problems.
> But:
> Is there any generic way to get a stable tomcat with huge number of jsp's ?

there was a thread on the developer list talking about thread pools and
expiration of web apps. I don't know about the state of this, but your
problem would probably be solved by this. 
If you could manage to make groups of webapps, let's say per day,
knowing that the servlets of a certain day never get used on the
following day, and if this thread webapp-cleaner was implemented, your
old webapps would get removed. You probably would be able to group your
jsps differently depending on your use.
Have a look at the thread named 
		Re: [PATCH] Re: ThreadPool
It's not yet there, but if it gets implemented, you can probably wait
using daily/nighly restarts of tomcat.
I don't see anything else if you don't have control of the content that
gets generated.

j.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: reducing tomcat & jasper memory footprint

Posted by Julian Löffelhardt <ju...@austria.fm>.
Hi,

My problem isin't javac memory leakes. Due to the apache/tomcat
documentation I was  aware of this an setup jikes as my jsp compiler. I'm
also using JDK 1.4.1 so the javac issues should be solved, nonetheless.
The main problem is as follows:
1. Every article & every page in general is a jsp page
2. All the pages are generated by a legacy CMS-System (imperia) and I can't
change the structure of it's works.
3. Every jsp page, once loaded, consumes memory, since the class remains
loaded.
4. We have 1000s of pages , every day some 200-300 new, so memory use
increases.

Conclusion:
The way we use jsp's for a cms is faulty. But I can't do anything about
this.
Increasing permSize of the JVM helps a lot. Maybe it would be a good idea to
include some hints about -XX:MaxPermSize and XX:PermSize into the
documentation because it really helps lessen the problems.
But:
Is there any generic way to get a stable tomcat with huge number of jsp's ?

Thanks for all ya feedback & llap + happy new year...

julian




----- Original Message -----
From: "Remy Maucherat" <re...@apache.org>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Monday, December 30, 2002 9:40 PM
Subject: Re: reducing tomcat & jasper memory footprint


> Paul Yunusov wrote:
> > On Monday 30 December 2002 02:37 pm, Julian Löffelhardt wrote:
> >
> >>Hi,
> >>
> >>I'm using Apache 1.3.26 and 3 tomcat 4.0.4 instances with AJP13 &
> >>loadbalancing . Our application is a CMS where all the published
articles
> >>are generated offline as JSP-Files, one jsp per article.
> >>
> >>We had hige problems with the memory footprint. Due to the fact that
every
> >>jsp is generated as a class and there are about 200 new artices per day
the
> >>permanent segment of the JVM heap gets filled with all the classes, and
I
> >>get an OutOfMemoryError. My workaround for now is setting -XX:PermSize
and
> >>--XX:MapPermSize to higher values, but this just delays application
> >>hang-up.
> >>
> >>With 64 megs of permSize our Server had an approx. uptime of 1 day now
it's
> >>about 3-4 days.
> >>
> >>Is there any way to unload jsp-Files (unload the class) ?
> >>
> >>llap,
> >>julian
> >
> >
> > JAVAC leaks memory every time a JSP class is compiled. The more JSPs are
> > compiled or the more often JSP classes are compiled, the more memory is
> > leaked. You exacerbate this problem by generating a JSP per article
often.
> >
> > IMHO, generating a JSP per article is misusing the technology. JSP is a
> > templating solution whereas one JSP describes a layout of any number of
end
> > documents. I suggest you change your software to generate an HTML file
per
> > artcile rather than a JSP.
>
> Maybe it's abusing the technology, but it really should work fine.
> Workarounds for the problem include using jikes, or using javac out of
> process (I don't quite remember how it is configured; since Jasper 2
> uses Ant javac task to compile, it should be in the Ant docs on the
> javac task).
>
> Remy
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: reducing tomcat & jasper memory footprint

Posted by Remy Maucherat <re...@apache.org>.
Paul Yunusov wrote:
> On Monday 30 December 2002 02:37 pm, Julian Löffelhardt wrote:
> 
>>Hi,
>>
>>I'm using Apache 1.3.26 and 3 tomcat 4.0.4 instances with AJP13 &
>>loadbalancing . Our application is a CMS where all the published articles
>>are generated offline as JSP-Files, one jsp per article.
>>
>>We had hige problems with the memory footprint. Due to the fact that every
>>jsp is generated as a class and there are about 200 new artices per day the
>>permanent segment of the JVM heap gets filled with all the classes, and I
>>get an OutOfMemoryError. My workaround for now is setting -XX:PermSize and
>>--XX:MapPermSize to higher values, but this just delays application
>>hang-up.
>>
>>With 64 megs of permSize our Server had an approx. uptime of 1 day now it's
>>about 3-4 days.
>>
>>Is there any way to unload jsp-Files (unload the class) ?
>>
>>llap,
>>julian
> 
> 
> JAVAC leaks memory every time a JSP class is compiled. The more JSPs are 
> compiled or the more often JSP classes are compiled, the more memory is 
> leaked. You exacerbate this problem by generating a JSP per article often.
> 
> IMHO, generating a JSP per article is misusing the technology. JSP is a 
> templating solution whereas one JSP describes a layout of any number of end 
> documents. I suggest you change your software to generate an HTML file per 
> artcile rather than a JSP.

Maybe it's abusing the technology, but it really should work fine.
Workarounds for the problem include using jikes, or using javac out of 
process (I don't quite remember how it is configured; since Jasper 2 
uses Ant javac task to compile, it should be in the Ant docs on the 
javac task).

Remy


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: reducing tomcat & jasper memory footprint

Posted by Paul Yunusov <py...@rogers.com>.
On Monday 30 December 2002 02:37 pm, Julian Löffelhardt wrote:
> Hi,
>
> I'm using Apache 1.3.26 and 3 tomcat 4.0.4 instances with AJP13 &
> loadbalancing . Our application is a CMS where all the published articles
> are generated offline as JSP-Files, one jsp per article.
>
> We had hige problems with the memory footprint. Due to the fact that every
> jsp is generated as a class and there are about 200 new artices per day the
> permanent segment of the JVM heap gets filled with all the classes, and I
> get an OutOfMemoryError. My workaround for now is setting -XX:PermSize and
> --XX:MapPermSize to higher values, but this just delays application
> hang-up.
>
> With 64 megs of permSize our Server had an approx. uptime of 1 day now it's
> about 3-4 days.
>
> Is there any way to unload jsp-Files (unload the class) ?
>
> llap,
> julian

JAVAC leaks memory every time a JSP class is compiled. The more JSPs are 
compiled or the more often JSP classes are compiled, the more memory is 
leaked. You exacerbate this problem by generating a JSP per article often.

IMHO, generating a JSP per article is misusing the technology. JSP is a 
templating solution whereas one JSP describes a layout of any number of end 
documents. I suggest you change your software to generate an HTML file per 
artcile rather than a JSP.

Paul

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: reducing tomcat & jasper memory footprint

Posted by Julian Löffelhardt <ju...@austria.fm>.
Hi,

I use jikes to compile the pages.
Since raising the JVM permanent segment size delays the error the problem
seems to come from the sheer size of the loaded class files.

So theorectically it shouldn't matter wheter the pages are precompiled or
not.

Anyway I 'm about to set up a test specifically for this, to measure how
many pages can be loaded before an error occurs.

llap,
julian



----- Original Message -----
From: "Jerome Lacoste (Frisurf)" <la...@frisurf.no>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Monday, December 30, 2002 8:51 PM
Subject: Re: reducing tomcat & jasper memory footprint


> Could this be also related to the leaks of the java compiler?
> Did you try to precompile the JSPs before deploying them (using JSPC) ?
> Perhaps does that help?
>
> Jerome
>
> On Mon, 2002-12-30 at 20:37, Julian Löffelhardt wrote:
> > Hi,
> >
> > I'm using Apache 1.3.26 and 3 tomcat 4.0.4 instances with AJP13 &
loadbalancing .
> > Our application is a CMS where all the published articles are generated
offline as JSP-Files, one jsp per article.
> >
> > We had hige problems with the memory footprint. Due to the fact that
every jsp is generated as a class and there are about 200 new artices per
day the permanent segment of the JVM heap gets filled with all the classes,
and I get an OutOfMemoryError.
> > My workaround for now is setting -XX:PermSize and --XX:MapPermSize to
higher values, but this just delays application hang-up.
> >
> > With 64 megs of permSize our Server had an approx. uptime of 1 day now
it's about 3-4 days.
> >
> > Is there any way to unload jsp-Files (unload the class) ?
> >
> > llap,
> > julian
> --
> Jerome Lacoste (Frisurf) <la...@frisurf.no>
> CoffeeBreaks
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: reducing tomcat & jasper memory footprint

Posted by "Jerome Lacoste (Frisurf)" <la...@frisurf.no>.
Could this be also related to the leaks of the java compiler?
Did you try to precompile the JSPs before deploying them (using JSPC) ?
Perhaps does that help?

Jerome

On Mon, 2002-12-30 at 20:37, Julian Löffelhardt wrote:
> Hi,
> 
> I'm using Apache 1.3.26 and 3 tomcat 4.0.4 instances with AJP13 & loadbalancing .
> Our application is a CMS where all the published articles are generated offline as JSP-Files, one jsp per article.
> 
> We had hige problems with the memory footprint. Due to the fact that every jsp is generated as a class and there are about 200 new artices per day the permanent segment of the JVM heap gets filled with all the classes, and I get an OutOfMemoryError.
> My workaround for now is setting -XX:PermSize and --XX:MapPermSize to higher values, but this just delays application hang-up.
> 
> With 64 megs of permSize our Server had an approx. uptime of 1 day now it's about 3-4 days.
> 
> Is there any way to unload jsp-Files (unload the class) ?
> 
> llap,
> julian
-- 
Jerome Lacoste (Frisurf) <la...@frisurf.no>
CoffeeBreaks


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: reducing tomcat & jasper memory footprint

Posted by Dan Payne <dp...@sotx.org>.
Could you explain this further? What exactly is the "many poor 'texts'"?

Thanks Torsten.

-Dan

-----Original Message-----
From: Torsten Fohrer [mailto:TFohrer@t-online.de]
Sent: Monday, December 30, 2002 4:39 PM
To: Tomcat Users List
Subject: Re: reducing tomcat & jasper memory footprint



the a bad thing is that the jasper generated code creates for each request
all
string object new. So hundred unneeded String objects consuming a lot off
memory. And so big pages with many poor "texts" without code....needs a big
amount of memory.

Torsten Fohrer

On Monday 30 December 2002 20:37, you wrote:
> Hi,
>
> I'm using Apache 1.3.26 and 3 tomcat 4.0.4 instances with AJP13 &
> loadbalancing . Our application is a CMS where all the published articles
> are generated offline as JSP-Files, one jsp per article.
>
> We had hige problems with the memory footprint. Due to the fact that every
> jsp is generated as a class and there are about 200 new artices per day
the
> permanent segment of the JVM heap gets filled with all the classes, and I
> get an OutOfMemoryError. My workaround for now is setting -XX:PermSize and
> --XX:MapPermSize to higher values, but this just delays application
> hang-up.
>
> With 64 megs of permSize our Server had an approx. uptime of 1 day now
it's
> about 3-4 days.
>
> Is there any way to unload jsp-Files (unload the class) ?
>
> llap,
> julian


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: reducing tomcat & jasper memory footprint

Posted by Torsten Fohrer <TF...@t-online.de>.
the a bad thing is that the jasper generated code creates for each request all 
string object new. So hundred unneeded String objects consuming a lot off 
memory. And so big pages with many poor "texts" without code....needs a big 
amount of memory.

Torsten Fohrer

On Monday 30 December 2002 20:37, you wrote:
> Hi,
>
> I'm using Apache 1.3.26 and 3 tomcat 4.0.4 instances with AJP13 &
> loadbalancing . Our application is a CMS where all the published articles
> are generated offline as JSP-Files, one jsp per article.
>
> We had hige problems with the memory footprint. Due to the fact that every
> jsp is generated as a class and there are about 200 new artices per day the
> permanent segment of the JVM heap gets filled with all the classes, and I
> get an OutOfMemoryError. My workaround for now is setting -XX:PermSize and
> --XX:MapPermSize to higher values, but this just delays application
> hang-up.
>
> With 64 megs of permSize our Server had an approx. uptime of 1 day now it's
> about 3-4 days.
>
> Is there any way to unload jsp-Files (unload the class) ?
>
> llap,
> julian


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


ServletContextListener cannot load Oracle JDBC driver

Posted by Peiqiang Han <pe...@videotron.ca>.
Hi,

I have a ServletContextListener which loads application resources from an Oracle database when application is installed. But a SQLException(see below) is thorwn becase DBCP cannot load JDBC driver. The JDBC driver(ojdbc14.jar) is installed in the ${CATALINA_HOME}/common/lib according to the instructions in the JNDI resources tutorial. I use 'ant install' task and DBCP connection pooling (commons-dbcp.jar are in ${CATALINA_HOME}/common/lib and WEB-INF/lib, but I d'ont think this is the problem). All work well until I want to load the resouces in the ServletContextListener(If I d'ont use the ServletContextListener, all work well). I use the follwoing environment:

Win2000 professional with SP3,
j2sdk-1.4.1_01
tomcat 4.1.8
Oracle 9i
JDBC driver : ojdbc14.jar (I have tried classes12.jar with jdk1.3.1, the problem also occurs).

Config in the server.xml:
  <DefaultContext>
  <Resource name="jdbc/ClassifiedDb" auth="Container"
                    type="javax.sql.DataSource"/>
           <ResourceParams name="jdbc/ClassifiedDb">
  <parameter>
   <name>username</name>
   <value>scott</value>
  </parameter>
   <parameter>
   <name>password</name>
   <value>tiger</value>
  </parameter>
  <parameter>
   <name>driverClassName</name>
   <value>oracle.jdbc.driver.OracleDriver</value>
  </parameter>
  <parameter>
   <name>url</name>
   <value>jdbc:oracle:thin:@localhost:1521:ora</value>
  </parameter>
  </ResourceParams>
   </DefaultContext>

The config in the web.xml
<resource-ref>
  <description>
    Resource reference to a factory for java.sql.Connection
    instances that may be used for talking to a particular
    database that is configured in the server.xml file.
  </description>
  <res-ref-name>
  jdbc/ClassifiedDb
  </res-ref-name>
  <res-type>
    javax.sql.DataSource
  </res-type>
  <res-auth>
    Container
  </res-auth>
</resource-ref>


java.sql.SQLException: Cannot load JDBC driver class 'null'
        at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou
rce.java:529)
        at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource
.java:312)
        at com.chinatown.classified.dao.AbstractDAO.getConnection(AbstractDAO.ja
va:51)
        at com.chinatown.classified.dao.CategoryDAO.findAllProvence(CategoryDAO.
java:46)
        at com.chinatown.classified.context.CategoryContextListener.contextIniti
alized(CategoryContextListener.java:73)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
t.java:3269)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:3
598)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:821)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:80
7)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:579)

        at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDep
loyer.java:257)
        at org.apache.catalina.core.StandardHost.install(StandardHost.java:772)
        at org.apache.catalina.servlets.ManagerServlet.install(ManagerServlet.ja
va:650)
        at org.apache.catalina.servlets.ManagerServlet.doGet(ManagerServlet.java
:342)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)

Any help will be apprecied.

Peiqiang Han

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: reducing tomcat & jasper memory footprint

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Mon, 30 Dec 2002, Julian Löffelhardt wrote:

> Date: Mon, 30 Dec 2002 20:37:10 +0100
> From: Julian Löffelhardt <ju...@austria.fm>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: Tomcat Users List <to...@jakarta.apache.org>
> Subject: reducing tomcat & jasper memory footprint
>
> Hi,
>
> I'm using Apache 1.3.26 and 3 tomcat 4.0.4 instances with AJP13 & loadbalancing .
> Our application is a CMS where all the published articles are generated offline as JSP-Files, one jsp per article.
>
> We had hige problems with the memory footprint. Due to the fact that every jsp is generated as a class and there are about 200 new artices per day the permanent segment of the JVM heap gets filled with all the classes, and I get an OutOfMemoryError.
> My workaround for now is setting -XX:PermSize and --XX:MapPermSize to higher values, but this just delays application hang-up.
>
> With 64 megs of permSize our Server had an approx. uptime of 1 day now it's about 3-4 days.
>
> Is there any way to unload jsp-Files (unload the class) ?
>

There is not.  But I can't help thinking that a better strategy might be
to use a single JSP page (or perhaps one per different layout of the
published articles) that build the content dynamically, instead of using a
separate JSP page per article.  Or else, maybe you could generate static
HTML files instead of JSP that then has to be compiled and executed every
time the article is read.

> llap,
> julian

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>