tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <>
Subject RE: Garbage Collection in Java: Am I an idiot?
Date Thu, 29 Aug 2002 13:21:57 GMT
Very few things are guaranteed regarding garbage collection when you
consider your system as a whole.  The container can almost always cache
things like JSPs, servlets, and sessions until it feels like releasing
them.  Some of these parameters you can control via configuration, e.g.
session expiration.  

System.gc() is a suggestion.  It doesn't guarantee garbage collection
will run.  In fact, JDK 1.4 and later can be told to ignore calls to
System.gc via a runtime option, so your server admin may set this
option, at which point you could rely on System.gc() even as a
suggestion to the VM.

Have your tried adding -verbose:gc to your runtime options?  That will
let you know when garbage collection is running and how much memory it
collected at each run.

Have your tried using another garbage collector, e.g. the incremental 
(-Xincgc) or concurrent mark-sweep (-XX:+UseConcMarkSweepGC (available
beginning with J2SE 1.4.1) ?  

Yoav Shapira
Millennium ChemInformatics

>-----Original Message-----
>From: Michael Nicholson []
>Sent: Thursday, August 29, 2002 9:08 AM
>To: Tomcat Users List
>Subject: OT: Garbage Collection in Java: Am I an idiot?
>The answer to the (completely rhetorical) question is probably yest,
>I've got another question, too.
>So, I have this moderately large application with jsps, servlets, and
>Oracle DB.  It does its thing ok, but it never releases memory.  There
>certainly session variables (probably way too many, but that's
>a question for another day), but even after the session expires, I'm
>using the same amount of memory.  I even included a direct call to
>System.gc() on my first page, hoping to collect the memory from the
>day old sessions, but no luck.
>So, my thoughts/questions:  Some connections are still opened (this is
>what's running on my development server right now: however, the actual
>development is done in Sun ONE on my desktop, so I'm going through and
>making sure all of those are closed there... but I'm also trying to
>this memory issue), so maybe these open connections force some of the
>session scoped beans to persist?  Forever?  Or am I just missing
>completely about garbage collection?
>So, in short, if I have a session scoped bean that has in it something
>a connection or a recordset (which is most likely not a good idea... I
>know that), even after the session times out, would that bean continue
>exist?  And eat up my memory?
>Sorry for the rambling.
>Michael Nicholson,
>Carolina Center for Public Service

View raw message