C++ how to prevent memory leaks ?

Visual Studio comes with a diagnostic tool which shows your CPU and memory usage over the course of your application lifetime. It’s probably not a very well known feature, but visual studio has a memory profiler tool which is VERY powerful. I have used it to find memory leaks successfully when I have had no idea where to begin looking. Basically, you can take a snapshot of your memory at any point in time (to set a baseline) and then continue taking memory snapshots. Each memory snapshot can be compared against other snapshots, so if you’re seeing memory being allocated and never being released as expected, then you’ve got memory leaks. I’ve been meaning to create an indepth tutorial on how to use this feature, but for now, I think I can point you to this article: