I've finally gotten around to learning about linked lists and all that. I understand that in a garbage collected environment, when a circular linked list head is dereferenced, the entire list is eventually GC'd.
I have quite a lot of experience with Objective-C and Swift which all use automatic reference counting instead of GC. As I understand it, this will create a strong reference cycle (as explained by Apple's ARC docs) since the head node will hold a strong reference to the back, which also holds a strong reference to the head. I've encountered strong retain cycles by accidentally doing exactly this.
This, in my mind, creates a major issue because it makes a circular linked list entirely unreleasable since under ARC, at least in Objective C and Swift, you cannot manually release objects.
Is the solution here to just to keep an extra weak reference property on each node for the "front" and "back" reference as they cannot use the common next
reference (as these would need to be strong or else nodes in the middle of the list would be deallocated)? Or should I be pseudo-manually deallocating my list by breaking all references in the list before I remove the final reference to the head? All of these seem less than beautiful and more hacks than solutions.