I like the way .NET does it where you can define regions to have the GC avoid running in [1]. You just need to declare how much memory the region should be able to allocate and it wouldn't run the GC unless it is exceeded. This is great for things like games where it's best to let the GC run while the GPU is rendering/presenting (note: not supported in Unity because they use Mono).
[1] https://learn.microsoft.com/en-us/dotnet/api/system.gc.tryst...
However, it requires changes in the language level, so no wonder so few languages like Zig implement it.
No, arenas don't really provide garbage collection, they are just a way to organizer your data in such a way that you can more easily collect the garbage later on, but you still need to do that yourself (e.g. decide when to free the whole arena). That article then goes on to show a bunch of what are basically small specialized allocators. It doesn't really solve the problem, it just moves it.
> However, it requires changes in the language level, so no wonder so few languages like Zig implement it.
What changes does Zig make to "implement" this?
The user has to pass the allocator around to all the functions that need to allocate data on the heap. I don't think every language is ready for that.
pron•5mo ago