0

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.

Thanks,
Adarsh

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

Edited by ~s.o.s~: Code inside code snippet

2
Contributors
1
Reply
16
Views
3 Years
Discussion Span
Last Post by JamesCherrill
1

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.

Votes + Comments
Yep; that's right.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.