Possible Duplicate:
What is the best way to check for memory leaks in c++?
There is a way to check for memory leaks after the program ended and also a way to check if there are areas of memory allocated and not yet released?
For example:
int main()
{
int *iPtr = new int;
// Was allocated memory that is not released yet?
return 0;
// Memory leaks?
}
On linux you can use valgrind. On windows you’ll have to search for allocation profiler (there’s Purify and AQTime 7), use _CrtDumpMemoryLeaks (msvc specific, may produce false positives) or write custom memory manager that overrides global operator new/delete and reports memory usage.