Hi,
Brand new to zig(and loving it), coming from a background of memory managed langs (go, java etc.)
I am a bit lost with deinit
. I understand that it should do cleanup and free any memory that it allocated.
How does this relate to when the object is instantiated using an arena allocator. From what I can gather, I should not deinit individual items and only deinit the arena allocator.
In my mind this presents two gaps. This would mean that an arena allocator is not a drop in replacement and would require additional changes to code. Iâm not saying that this is a problem but naively, I anticipated it to work more polymorphically.
Secondly, this also means that deinit
should be used exclusively for deallocation. If it does any other cleanup, it may end up not being called if the object was instantiated with an arena allocator - or deinit needs to be called on it anyway, which would negate the benefit of using the arena allocator (at least for that object).
I have tried to find some conclusive documentation around deinit and what it should do, but could not find any. If there is some documentation somewhere, perhaps that would answer my questions?
I would appreciate any help and explanations.
Thanks in advance,
Shri