[Dlang-internal] Is there has document that about dlang GC design and implement?
mw
mingwu at gmail.com
Sun May 24 17:47:52 UTC 2020
On Sunday, 24 May 2020 at 16:12:44 UTC, mw wrote:
> On Friday, 18 October 2019 at 07:07:06 UTC, lili wrote:
>> exclude read source, how to learn GC implement。
>
> Google search “gc document site:dlang.org”
>
> may find some info, e.g.
>
> https://wiki.dlang.org/DIP46
https://dlang.org/spec/garbage.html
esp.
https://dlang.org/spec/garbage.html#how_gc_works
How Garbage Collection Works
The GC works by:
Stopping all other threads than the thread currently trying to
allocate GC memory.
‘Hijacking’ the current thread for GC work.
Scanning all ‘root’ memory ranges for pointers into GC allocated
memory.
Recursively scanning all allocated memory pointed to by roots
looking for more pointers into GC allocated memory.
Freeing all GC allocated memory that has no active pointers to it
and do not need destructors to run.
Queueing all unreachable memory that needs destructors to run.
Resuming all other threads.
Running destructors for all queued memory.
Freeing any remaining unreachable memory.
Returning the current thread to whatever work it was doing.
More information about the Dlang-internal
mailing list