The one secret method of avoiding memory leaks in C++ So just enable this in your compiler -fsanitize=address The end.