I have an array list:
private ArrayList<PerfStatBean> statFilterResults;
I want to iterate through it like:
Iterator<PerfStatBean> statsIterator = statFilterResults.iterator();
while(statsIterator.hasNext()){
i++;
PerfStatBean perfBean = statsIterator.next();
.........
I would like to delete the bean from statFilterResults after I run through it inside the while loop to free up memory. I believe if I do something like
perfBean = null;
it won’t do the job as the perfBean reference will be null but the object will still be in memory.
Any ideas?
Thanks,
Tam
This probably isn’t a great optimisation. If the memory requirements are large, then you probably don’t want to store them all in a list in the first place – process the objects as they are created.
However, taking the question literally,
ListIterator.setis the method for you.