Before taking the next steps to eliminate memory leaks, try your best to craft your app from encapsulated and independent classes. One more note. For the most part I agree with him, but this macro really is just a substitute for lines of code, so I think it's the best way to do it. If you know a better way, please write me . Class member variable pointers Generally speaking, most heap-allocated objects start their lives as pointers in the private part of classes.
Chances are they're allocated with a new command in that classes constructor.
I like to make sure the object was really allocated, so I make sure the pointers start their lives as null. Sometimes the pointer isn't new'ed in the constructor, but in a method that can be called over and over. A good example is a string-constructing method which allocates memory sufficient to hold the finished string. The if the method above is called 1000 times in a loop, you'll end up with one valid char pointer and 999 disembodied memory chuncks. Here's the code.