Hi All,

I need some help with analysing a problem. I have a list of objects that are retreived as part of search results in my webapp page.

From the list of these objects, one object is selected and the next screen is populated with the data from this object.

List<MyCustomObject> objects = // data from DB 
// on user select 
MyCustomObject selectedObj = objects.get(i);
return selectedObj;

Since there is a reference to one of the objects in the list, will the list be eligible for garbage collection in this case ?

I am running the performance and memory analyzer tool on eclipse and cant seem to get this list of objects off my webapp memory. It always stays in memory though its not a global variable.

Any help would be very much appreciated.


EDIT : Its been some time since i wrote a thread, sorry i am unable to add that snippet as a code.

Holding a ref to an object that's in a list won't affect the list's reference count because the object does not have a reference to the list. Either you have a reference to the list itreslf that's still active, or maybe GC just hasn't got round to deleting it yet.

commented: Yep; that's right. +0