GC.collect inflating memory usage?

Rainer Schuetze r.sagitario at gmx.de
Sat Dec 7 20:05:06 UTC 2019


On 07/12/2019 12:20, cc wrote:
> Given the following program:
[...]
> But when both FREE and COLLECT are enabled, things seem to spiral out of
> control:
>     // FREE, COLLECT
>     Stats(16, 1048560, 16)
>         848     4096
>     40960832  40964096
>     81920832  81924096
>     122880832  122884096
>     163840832  163844096
>     204800832  204804096
>     245760832  245764096
>     286720832  286724096
>     327680832  327684096
>     368640832  368644096
>     Elapsed: 29143 ms
> 
> I wouldn't normally call GC.collect on every frame in my application,
> but I'm curious why this is happening and if there is unnecessary bloat
> being added somehow when I do choose to call GC.free manually and
> garbage collection later occurs in a long-running program.  Ideally I'd
> like to free up as many objects and arrays as soon as they become unused
> to avoid lengthy collections reducing performance.  I know that
> std.container.array is one alternative to using D's GC-managed dynamic
> arrays, but could I run into the same issue when trying to manually
> deallocate class objects as well?
> 
> Using DMD32 D Compiler v2.089.0-dirty
> 

Seems like a bug introduced in dmd 2.086, I've created a bugzilla issue:
https://issues.dlang.org/show_bug.cgi?id=20438

I suspect there is something broken with respect to the free-lists
inside the GC when manually freeing memory :-/


More information about the Digitalmars-d-learn mailing list