I have just resolved a memory leak in my application and now I want to write a unit test to ensure that this does not happen again.
I\'m look for a way to detect th
You can also use google test framework (gtest) and then use google performance tools (gperf) to find leaks. GPerf puts in a replacement memory library and if there is a memory leak found after the test run completes it will let you know and gives you a pprof command to run with several different output formats - text, dot, web, etc. This tool will find leaks in both tests and production code.
I also use Valgrind to confirm if there is a leak when questionable but prefer gperf. One gotcha is that if you have compiled with the gperf memory library and try to use Valgrind, it won't find any issues because it catches the leaks so you need to clean compile between switching or have a second copy of the project.