Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Garbage collection not happening?

Re: Garbage collection not happening?

From: adam <aflynn_at_mrcuk.com>
Date: 2 Sep 2002 04:06:26 -0700
Message-ID: <4c3a15f9.0209020306.59814ee7@posting.google.com>

> MyObject mo;
> List l = new ArrayList();
> while (rs.next())
> {
> mo = new MyObject();
> mo.setData1(rs.getString("data1"));
> mo.setData2(rs.getString("data2"));
> ...many more similar calls...
> l.add(mo);
> }

In the example you gave above none of the MyObjects can get garbage collected because each one has a reference remaining within the array list. In the second example you gave below, the objects are all available for garbage collection straight away.

> for (int i = 0; i < 10000; i++)
> {
> new ArrayList(10000);
> new String();
> new StringBuffer(100000);
> }

In short, objects are only available for garbage collection when the garbage collector determines that the program can no longer access them. Even then, there is no guarantee when or if redundant objects will be collected: it pretty much depends on the garbage collector implementation. Received on Mon Sep 02 2002 - 06:06:26 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US