teknomunk (teknomunk@apogee.polaris-1.work)'s status on Tuesday, 16-Apr-2024 11:24:01 JST
-
Embed this notice
@karna @binkle @hazlin
Going to drop in here to give what I know about the subject. I don't have any particular insight into python.
When using referencing counting, you can release the memory to the allocator as soon as they reach zero references or you can queue them up for later releasing. This works reasonably well, but as you pointed out: cycles exist and make reference counting fail.
A tracing garbage collector is one of the solutions for automaticly releasing memory that is no longer needed. It traces the graph of every memory allocation that is still reachable from global variables and the stack and marks everything that is reachable and throws away everything else.
As I under it, python mostly uses reference counting, but falls back to a tracing garbage collector for dealing with cycles.