In theory, garbage collectors make memory leaks a thing of the past. In practice, garbage collectors don't always work according to theory. This makes me curious: how does one test for memory leaks in a D program?
I also don't know how smart or dumb garbage collectors are. How much help does it need? Okay, that is too general a question. So take a for- instance. Consider a circular linked list that we are done with. Each node has a reference to it (from another node in the list). But, being done with the list, we imagine that there are no references from outside the list to any node. Is D's garbage collector smart enough to deal recognize the circle of nodes as garbage? Is it necessary or at least helpful to set all the circle's links to null before being done with it? I assume that reference counting collectors are not smart enough to handle an abandoned circular list. But D's GC is not a reference counter. I don't know how smart GC's get. Is it okay to leave a single node linking to itself? Another for-instance. Consider this time a linear linked list. This time, the list is finite: it terminates with a node pointing to null. Are the issues here any different? Thanks in advance for any insights.