How do you know you have a memory leak ?
If you have the class (and the constructor) code then it should be easy to trace the code and pin-point the memory allocations or more importantly, the non-existant memory de-allocation.
If you put the class in a simple project and create an instance of the class on the stack and exit the process normally, does it leak ? (i.e. is the debugger listing memory leak at the end of the debuggin session?)
for example :
class YouClass;
int main(...)
{
YourClass yourClass;
return 1;
}
does that leak ?
if you allocate on the heap with
new
, do you delete the memory with
delete
?
class YouClass;
int main(...)
{
YourClass* yourClass = NULL;
yourClass = new YourClass;
delete yourClass;
yourClass = NULL;
return 1;
}
If the simple program leaks, check the class and track allocation, and also de-allocation, especially in the
destructor
.
Max.