tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Saurabh Arora" <>
Subject RE: Memory Usage and Garbage Collection
Date Fri, 03 Jan 2003 09:33:17 GMT
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


>>> 01/03/03 02:26PM >>>
Hi Craig,

please see intermixed.

On 2 Jan 2003 at 18:18, Craig R. McClanahan wrote:

> Instances can be garbage collected IF AND ONLY IF there are no
> live references to that object in a static/instance/local
> variable of some other object that is also in memory.  Only
> instances that are no longer referenced from other object
> instances can be recycled.

Please consider the following service() or doGet() or so of a 

public void service(ServletRequest request, ServletResponse 
   throws IOException
  OtherObject otherObject = new OtherObject();
  otherObject.doThisAndThat(request, response);

Do I have to place the following
otherObject = null;
before the end of service(). Doesn't otherObject be gc-ed 
otherwise? I've never done this.

What about the object instances, which 
otherObject.doThisAndThat() creates? So far I've thought there 
are no live references if otherObject gets gc-ed.

> In the case at hand, Tomcat (obviously) has references to all the
> servlets that it has loaded.  Therefore, those servlet instances
> cannot be garbage collected.  Furthermore, any object that is
> referenced by static or instance variables of your servlet class
> can *also* not be garbage collected, because live references
> still exist.  Same thing for session attributes.

OK, this is obvious.


deleted the latter parts...

To unsubscribe, e-mail:  
For additional commands, e-mail:

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message