You can track memory leaks by counting successful allocations and deallocations. Actually, if you have a leak and a double-free bug, the counter won't work. You have to get vastly more exotic to get ...