Ask a Question
Advertise on boostr.in
Organizational Research By
Surprising Reserch Topic
how does java garbage collector handle self reference using -'java,garbage-collection'
how does java garbage collector handle self reference ¬†using -'java,garbage-collection'
Hopefully a simple question. Take for instance a Circularly-linked list:
¬†¬†private listContainer next;
¬†¬†public void setNext(listContainer next)
¬†¬†¬†¬†this.next = next;
¬†¬†private listContainer entry;
Now since it's a circularly-linked list, when a single elemnt is added, it has a reference to itself in it's next variable. When deleting the only element in the list, entry is set to null. Is there a need to set ListContainer.next to null as well for Garbage Collector to free it's memory or does it handle such self-references automagically?
Sep 7, 2015
to add a comment.
Related Hot Questions
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
To avoid this verification in future, please