3 ms·
> 3. No, mark-sweep garbage collection can be made to coexist with C++-style memory management. GC depends on being able to find all valid pointers. C++ allow
by anamax 16y ago
> 3. No, mark-sweep garbage collection can be made to coexist with C++-style memory management.
GC depends on being able to find all valid pointers. C++ allows pointer games, like the xor trick for doubly-linked lists, which hide pointers. (It uses a single pointer field in each element to represent both the forward and backward pointer.)
GC can't collect things that are algorithmically inaccessible. There are algorithms that are efficient because they don't kill pointers to objects that are no longer in use.
I like GC, but there are costs.