This project is supposed to be a memory leak detector for me, but I've tried to make it more stranger-friendly with configuration macros defined in mhshim.h
.
It's simple. First you need to understand how the memory leak detector works. It's a shim. It edits the functions malloc, calloc, realloc, free
.
What are the modifications? It uses a linked list to store void pointers and their sizes. It's not like the original allocation and deallocation functions aren't being used.
They're also being used with the help of dlsym
.
You need to know how to execute bash scripts(for compilation).
You also need to know what environment variables are. More specifically, what LD_PRELOAD
is. After compilation is done, you should see a .so file.
That is a shared object file. You need to set LD_PRELOAD
to ./(shared object path) ./(target executable)
. This will be automated in the future
with the help of functions like setenv, fork, execvp
.
This only works on unix-based operating systems.