I would like to expand an existing tool with the functionality of a memory debugger (just leak detection).
I know that some memory debuggers work by replacing malloc/free and keeping track of what is pending to be freed and who allocated it; or by running the process on sort of a virtual machine and monitoring memory accesses.
I want to know if it makes sense to use ptrace()
to set breakpoints on malloc/free, instead rebuilding with dmalloc for example, and monitoring allocations in a separate process. Would it be too slow? Does any other tool work this way?