Minimize GC memory footprint

frame frame86 at live.com
Sat Feb 6 02:14:26 UTC 2021


On Friday, 5 February 2021 at 22:46:05 UTC, Bastiaan Veelo wrote:

> I think it means that you need to make sure that enable() is 
> called as many times as disable() is called before collection 
> can happen automatically.
>
> — Bastiaan.

Thanks, in the meanwhile I looked into the source:

> struct Gcx
> {
>    uint disabled; // turn off collections if >0
> ...
> }

> void enable()
> {
>    static void go(Gcx* gcx) nothrow
>    {
>        assert(gcx.disabled > 0);
>        gcx.disabled--;
>    }
>    runLocked!(go, otherTime, numOthers)(gcx);
> }

> void disable()
> {
>    static void go(Gcx* gcx) nothrow
>    {
>        gcx.disabled++;
>    }
>    runLocked!(go, otherTime, numOthers)(gcx);
> }

So that explains what's going on.

The assertion should kick in to warn about this issue. But it 
doesn't work on user code.
I assume the runtime is not compiled but just linked or do I need 
another argument switch?


More information about the Digitalmars-d-learn mailing list