tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject RE: Memory Usage and Garbage Collection
Date Fri, 03 Jan 2003 19:42:49 GMT


On Fri, 3 Jan 2003, Saurabh Arora wrote:

> Date: Fri, 03 Jan 2003 02:33:17 -0700
> From: Saurabh Arora <Sarora@novell.com>
> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> To: tomcat-user@jakarta.apache.org
> Subject: RE: Memory Usage and Garbage Collection
>
> Just wanted to know, does the current implementation of tomcat 4.1.18
> also has the same problem of keeping the jsp's
>  in memory. or it was only present in 4.0.4
>

It's not a *problem* -- it's a *feature* :-).  This is one of the keys to
maintaining good performance on repeatedly requested pages.

Yes, Tomcat 4.1.x maintains a reference to every JSP page that has ever
been requested (same as every servlet that has ever been requested) until
that webapp is reloaded or removed, or you shut down Tomcat.

Given this, designing webapps where you auto-generate hundreds of
different JSP pages (which was the choice of the originator of this
message thread) is not what you really want to do.  Instead, you'd want to
use a single JSP page for each basic *style* of output (essentially the
JSP page would be a formatting template) that pulls in the unique
information for a particular report (from the database, from XML, or
whatever) dynamically.  Then, a given webpp would likely have 5-10 JSP
pages, instead of hundreds.

Just as an example, assume that your application back-end gave you the
data you need in some XML format, and you want to offer your user the
chance to format this data in ten different ways.  If you create an XSLT
stylesheet to transform the data for each of the ten formats, you can do
this all with a *single* JSP page that takes an XML data source and an
XSLT stylesheet, applies the transformation, and renders the result.
(JSTL has a tag that will do all the grunt work for you.)

If you really really want to auto-generate all the reports ahead of time,
go ahead and generate static HTML pages -- don't waste your time
generating JSP that then has to get compiled, loaded, and executed.  As a
side benefit, the output will get served a little faster because there is
less overhead in serving static files.

If you really really really want to generate hundreds of JSP pages, then
plan on buying enough memory to hold them all and be done with it.
Fortunately, this is not usually a "break the bank" decision (I just
upgraded my development PC to a gigabyte of memory for less than $100 :-).

If you really really really really want to generate hundreds of JSP pages,
and don't (or can't) afford the memory to hold them all, you only have
yourself to blame for the results.

>
> saurabh

Craig


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message