Do you use D's GC?

Steven Schveighoffer schveiguy at gmail.com
Tue Aug 3 14:34:19 UTC 2021


On 8/3/21 5:15 AM, Gregor Mückl wrote:
> On Sunday, 1 August 2021 at 08:54:05 UTC, Kirill wrote:
>> It's interesting to hear do you use D's GC? Or do you use your own 
>> custom memory management structure?
>>
>> How performant is GC?
>>
>> The reason I'm asking is I'm planning to dive into 3D game dev with D 
>> as a hobby in an attempt to create a game I dreamed of since I was a 
>> kid. I'd like to know if GC is worth using at all, or should I go with 
>> 100% manual memory management.
>>
>> Any opinion is appreciated. Thanks in advance.
> 
> The D garbage collector seems reasonable for applications with small 
> (object sized) allocations. But that changes when you allocate large 
> blocks of memory: due to a bug internal to the tracking of allocated 
> pages, performance gradually degrades over time. So if you have to 
> allocate large(ish) buffers regularly, it'll show over time. I reported 
> that bug here with a repro case, but it didn't get any attention yet:
> 
> https://issues.dlang.org/show_bug.cgi?id=20434
> 
> I haven't managed to understand thag part of the GC enough to submit a 
> patch myself :(.

Is that repro case doing what you think it is doing? It appears to keep 
adding more and more larger allocations to the mix.

It seems you are calculating a `size` variable and never using it.

I think possibly you meant to use `size * 1024 * 1024` instead of `i * 
1024 * 1024`.

In regards to the conservative nature of the GC, the larger the blocks 
get, the more chances they get "accidentally" pointed at by the stack 
(or some other culprit). 64-bit memory space should alleviate a lot of 
this, but I think there are still cases where it can pin data 
unintentionally.

-Steve


More information about the Digitalmars-d mailing list