Could someone calrify reserving and collecting memory via the Garbabe Collector ?
rikki cattermole
rikki at cattermole.co.nz
Thu Aug 6 17:18:12 UTC 2020
On 07/08/2020 5:12 AM, wjoe wrote:
> There's core.memory.GC.reserve which requests memory from the OS.
> Basically pre-allocating memory for the GC heap.
>
> Is the GC heap shared among all threads ?
That is up to the GC implementation.
> And is it correct that even if I call GC.disable, the GC may still start
> a collection run if, for instance, there's an allocation but no free
> memory on the GC heap ?
"Disables automatic garbage collections performed to minimize the
process footprint. Collections may continue to occur in instances where
the implementation deems necessary for correct program behavior, such as
during an out of memory condition. This function is reentrant, but
enable must be called once for each call to disable."
https://dlang.org/phobos/core_memory.html#.GC.disable
So yes.
Note, out of memory is related to the process, rather than GC internals
(it does play a part, but lets just go with process).
More information about the Digitalmars-d-learn
mailing list