Which is the most reliable way to find a memory leak in a C++ program?
- A Reading the code carefully
- B Running under a tool such as Valgrind or AddressSanitizer with leak detection
- C Adding print statements
- D Increasing the heap size
Answer
Running under a tool such as Valgrind or AddressSanitizer with leak detection
The structural fix is to eliminate the possibility by using RAII and smart pointers rather than raw owning pointers.





