 int main(void) {

$ MALLOC_TRACE=/home/YourUserName/path/to/program/MallocTraceOutputFile.txt
$ export MALLOC_TRACE


mtrace();

muntrace();

$ gcc yourProgram.c -g
$ ./a.out

$ mtrace   

$ mtrace a.out MallocTraceOutputFile.txt

if (my_rank==0) mtrace();
If the mtrace command reports “No Memory Leaks”, then all memory that was allocated in the last execution of that program was also released, which is the way it should be.If, on the other hand, mtrace gives output such as that below, it means the programmer still has some work to do.Memory not freed