Menu

Post image 1
Post image 2
1 / 2
0

Avoiding The GC in D: Stack, Buffers & Arenas

DEV Community·Kapendev·24 days ago
#aouun508
Reading 0:00
15s threshold

It's common to see new D users talking about @nogc and -betterC when discussing Manual Memory Management (MMM). In a way, it makes sense. Both are closely related to it based on their names. One of them is literally called "no GC." This might sound strange given their names, but neither @nogc nor -betterC is actually MMM. They don't tell you how memory is allocated or when allocation happens. A @nogc function could allocate or it could not. What they do tell you is that one type of allocator, the GC, is not being used. That only rules out one allocator. The TL;DR is that both of those features are compiler-enforced GC restrictions with: @nogc : also being part of the type system. -betterC : also removing the D runtime. In this post, I will skip over -betterC since removing the D runtime is a topic of its own. I'll go over how to do manual memory management in D and how to avoid the GC without fighting the language. Stack Memory Let's start with the stack.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More