tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From William Kaufman <>
Subject RE: memory allocation
Date Thu, 14 Jun 2001 20:22:15 GMT
The only time you need to set a variable to null is when the variable itself
sticks around (e.g., a class variable, or an instance variable on some
object on a class variable).  You never have to null out local variables.

This is a general Java question, not a Tomcat question.  If my answer didn't
make sense, ask on, or on a Java mailing

                                        -- Bill K. 

-----Original Message-----
From: Luba Powell []
Sent: Thursday, June 14, 2001 12:11 PM
Subject: Re: memory allocation

Not to worry.
The only time that I know you need to set objects to null
is when you write servers and inside you (while (true)..
eternal loop.

----- Original Message -----
From: <>
To: <>
Sent: Thursday, June 14, 2001 1:41 PM
Subject: memory allocation

hi all , i want to ask something about jsp pages

sample jsp code  =
<%@ page import = "java.util.*" %>
<%@ page import = "MyBean" %>
<%@ page contentType="text/html;charset=ISO-8859-9" %>

<jsp:useBean id="my_bean" class="MyBean" scope="page"/>


ArrayList al = new ArrayList();

mybean.showData(al); // we are going to fill
Iterator it = al.iterator();
while( it.hasNext() ) {
} //while

al = null ; // should i  do this ?  or is it going to be
garbage collected by itself
it = null  ; // shoul i do this   ? or is it going to be
garbage collected by itself


my_bean  object will be garbage collected  because it' scope is page but
what about  ArrayList and Iterator  objects  ?



Altug B. Altintas

View raw message