java - Are linked lists collected by the GC when the first list item is unreachable? -
i have doubly linked list of objects:
class myobject { myobject previousobject; myobject nextobject; // other fields , methods }
only first object of such list straight stored in application, other objects reached through first object , temporarily used in application (but no permanent references kept outside list itself).
when 1 not refer object anymore, collected garbage collector.
but, wondering whether still case, because (first) object still beingness referenced 'next object' in linked list? , rest of list, objects collected (even though beingness referenced each other)?
note: know remove references in list when not utilize anymore. 'hard' due nature of application , results in additional (unnecessary?) overhead.
the gc doesn't utilize reference counting, circular dependencies handled fine. don't need anything, , whole list garbage collected when no element of list reachable anymore.
java android garbage-collection linked-list
No comments:
Post a Comment