Open daurnimator opened 5 years ago
This is a good idea. At least the general purpose allocator that we eventually have should support this, in debug mode. We'll need to balance it with the use case of comptime allocation (see #1291). (Maybe that can be solved with "use this special allocator" for comptime allocation).
Also related #896
And #480
@daurnimator your pull request was a great start to tackling this issue. It was the basis for solving #460 which is now integrated directly into the codegen of the compiler. I merged the std.valgrind
module but I removed the integration with std.mem.Allocator
for now. I want to work towards solving #1291 and this issue at the same time. For future reference, the integration with std.mem.Allocator
code can be found here: https://github.com/ziglang/zig/commit/d633dcd07a053d76942217ca845ff2735a0ce6a2
This issue is still open, and I'm not sure yet how exactly the integration will work, whether it goes into the Allocator interface, or implementations, or something special. Whatever happens, thanks to @daurnimator's work, it's now possible for zig users' custom allocators to add valgrind integration, and example integration can be found in the above linked commit.
To find memory leaks in zig programs, the standard library allocators should inform valgrind about allocations/frees.
This has a dependency on making valgrind client requests possible from zig code.
valgrind/valgrind.h
is a gnarly piece of code!Valgrind docs: http://valgrind.org/docs/manual/mc-manual.html#mc-manual.clientreqs
Related to