You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Generic leak checking for all allocators, and allocator-like data structures #3075
Currently the stackAllocator and the memory pools have fairly limited leak checking, only telling you that something leaked, not where it was allocated, and even worse, I would like to remove leak checking from the memory pool to avoid the need to deinit it.
The fix for this would be relatively simple, we just create one global map that contains all the allocations and their trace, then every time an allocation happens in the relevant allocators, we just call heap.registerAllocation(ptr, len, trace) which adds an entry for ptr to the hashmap, and heap.unregisterAllocation(ptr, len) which removes the entry.
Then on application close we just print the remaining entries.
The DebugAllocator from std does something similar, but it is not usable from the outside.
I don't feel great about having to call some other function for every allocation to register it.
I think we should create some wrapper around the allocator that handles registration for us.
Also - how do we obtain the trace? I'm not sure whether it's intended for the programmer to just write a string there to describe where the allocation happened, or if there's some automated way of doing it properly in Zig.
This would be handled by the data structures internally (GPU allocator, memory pool, stackallocator), not something you need to do manually everywhere.
As for how to obtain the trace, just checkout Zig's DebugAllocator.
Activity
Require the memory pool to be initialized with an arena (#3077)
BoySanic commentedon Jul 27, 2026
I don't feel great about having to call some other function for every allocation to register it.
I think we should create some wrapper around the allocator that handles registration for us.
Also - how do we obtain the trace? I'm not sure whether it's intended for the programmer to just write a string there to describe where the allocation happened, or if there's some automated way of doing it properly in Zig.
IntegratedQuantum commentedon Jul 28, 2026
This would be handled by the data structures internally (GPU allocator, memory pool, stackallocator), not something you need to do manually everywhere.
As for how to obtain the trace, just checkout Zig's DebugAllocator.