Empty an ArrayList or just create a new one and let the old one be garbage
collected?
What are the advantages and disadvantages of emptying a collection (in my
case its an ArrayList) vs creating a new one (and letting the garbage
collector clear the old one).
Specifically, I have an ArrayList<Rectangle> called list. When a certain
condition occurs, I need to empty list and refill it with other contents.
Should I call list.clear() or just make a new ArrayList<Rectangle> and let
the old one be garbage collected? What are the pros and cons of each
approach?
No comments:
Post a Comment