https://issues.dlang.org/show_bug.cgi?id=24331

timon.g...@gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.g...@gmx.ch

--- Comment #2 from timon.g...@gmx.ch ---
(In reply to Walter Bright from comment #1)
> Sounds like better documentation is needed for both @nogc and GC.disable().

Well, currently, the spec states:

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.

https://dlang.org/spec/garbage.html

So what people are relying on is currently indeed specified behavior. This can
of course be changed, but I do not think we can fault users for relying on this
documented behavior of the GC.

--

Reply via email to