|
|
|
|
|
by necubi
2021 days ago
|
|
The simplest way to do this is to use the low bit of the address (so long as you align your memory to at least 2 bytes this is fine as all addresses will end in 0) as a marker for whether you've already visited that pointer. See https://en.wikipedia.org/wiki/Tracing_garbage_collection#Na%... And yes, you're correct that GCs handle cycles without issue (that's a large part of the reason to use tracing GC over other memory management strategies like ObjC's auto-reference counting). |
|
[1]: https://en.wikipedia.org/wiki/Cycle_detection#Floyd.27s_Tort...