Minimize GC memory footprint
rikki cattermole
rikki at cattermole.co.nz
Sat Feb 6 13:30:03 UTC 2021
On 07/02/2021 12:38 AM, Siemargl wrote:
> On Saturday, 6 February 2021 at 11:20:18 UTC, Imperatorn wrote:
>> On Saturday, 6 February 2021 at 09:42:38 UTC, rikki cattermole wrote:
>>> On 06/02/2021 3:32 PM, frame wrote:
>>>> [...]
>>>
>>> This won't do anything.
>>>
>>>> [...]
>>>
>>> Don't forget to stdout.flush; Otherwise stuff can get caught in the
>>> buffer before erroring out.
>>>
>>>> [...]
>>>
>>> Turn on the precise GC, 32bit is a bit too small of a range and you
>>> can get false positives like in this case (at least looks like it).
>>
>> For reference, how does one turn on precise GC?
>
> https://dlang.org/spec/garbage.html#gc_config
>
> Strange things happens:
> - precise scanning dont change result - OOM @ same round 27
Okay, its still seeing something is alive then.
> --DRT-gcopt=help wont show used gc implementation, also cleanup type
> not printed
https://github.com/dlang/druntime/blob/master/src/core/gc/config.d#L36
> - maxPoolSize:N dont limit total size of GC
Shouldn't change anything, except make OOM happen faster.
> - in gc:manual mode GC.collect() not releasing memory
https://github.com/dlang/druntime/blob/master/src/gc/impl/manual/gc.d#L84
>
> When i print free GC memory, it seems to memory leaking
> writefln("Usage: %.2f MiB (free %.2f MiB) / collected: %d",
> (cast(double) GC.stats.usedSize) / 1_048_576,
> (cast(double) GC.stats.freeSize) / 1_048_576,
> GC.profileStats.numCollections);
> stdout.flush();
I've compiled and ran it under ldc. Dmd in 32bit mode is certainly doing
something that the GC doesn't appreciate. I can reproduce it with
-m32mscoff as well. So yeah dmd specific all right.
More information about the Digitalmars-d-learn
mailing list