Hi everybody
I am writing a console app in C++ under XP and I would like to be able to test for memory leaks.
In my program I create a number of variables and objects on the free store but I am unsure if my code cleans them up correctly.
I've been using the Processes tab under Task Manager to keep track of how much memory is being used through out the execution of my app. I've noticed that when I create a new variable the Mem Usage increases but when I delete that same variable it does not decrease. This has led me to believe I have a memory leak. However, when I create a second variable of the same type the Mem Usage does not increase nor does it decrease when I delete that variable. This is confusing me greatly - can anybody point me in the direction of a better (and if possible free) tool for keeping track of what memory my app is using as it runs. Or can anybody point me in the direction of some code I can place in my app to report the amount of memory it is using.
I've included a little test program I've written to see how Task Manager reports memory usage and to better explain what i mean.
CODE PORTION---------------------
int* pnumber;
pnumber = new int[10];
//Mem usage increases by 4k
delete pnumber;
//Mem usage stays the same (would expect it to decrease)
pnumber = new int[10];
//Mem usage stays the same (would expect it to increase)
delete pnumber;
//Mem usage stays the same (would expect it to decrease)
cout << endl << endl << "END OF PROG";
cout << endl;
return 0;
END-----------------------
Thank you for your time
Andrew
I am writing a console app in C++ under XP and I would like to be able to test for memory leaks.
In my program I create a number of variables and objects on the free store but I am unsure if my code cleans them up correctly.
I've been using the Processes tab under Task Manager to keep track of how much memory is being used through out the execution of my app. I've noticed that when I create a new variable the Mem Usage increases but when I delete that same variable it does not decrease. This has led me to believe I have a memory leak. However, when I create a second variable of the same type the Mem Usage does not increase nor does it decrease when I delete that variable. This is confusing me greatly - can anybody point me in the direction of a better (and if possible free) tool for keeping track of what memory my app is using as it runs. Or can anybody point me in the direction of some code I can place in my app to report the amount of memory it is using.
I've included a little test program I've written to see how Task Manager reports memory usage and to better explain what i mean.
CODE PORTION---------------------
int* pnumber;
pnumber = new int[10];
//Mem usage increases by 4k
delete pnumber;
//Mem usage stays the same (would expect it to decrease)
pnumber = new int[10];
//Mem usage stays the same (would expect it to increase)
delete pnumber;
//Mem usage stays the same (would expect it to decrease)
cout << endl << endl << "END OF PROG";
cout << endl;
return 0;
END-----------------------
Thank you for your time
Andrew