I allocated a buffer in my app like below:
char* ptr = new char[variable]; // its has a variable size but this is known before calling this line
char* ptr = new char[variable]; // its has a variable size but this is known before calling this line
To copy to clipboard, switch view to plain text mode
then i pass that pointer to my class
myClass* c = new myClass(ptr);
myClass* c = new myClass(ptr);
To copy to clipboard, switch view to plain text mode
in my myClass constructor and destructor
myClass::myClass(char* ptr)
{
m_ptr = ptr; //m_ptr is a private char* pointer
}
myClass::~myClass
{
delete [] m_ptr;
}
myClass::myClass(char* ptr)
{
m_ptr = ptr; //m_ptr is a private char* pointer
}
myClass::~myClass
{
delete [] m_ptr;
}
To copy to clipboard, switch view to plain text mode
I expected this to free up the buffer everytime i deleted the object myClass but i was wrong. I am monitoring my app in task Manager and it is still using a lot of memory even after deleting myClass. please tell me where did i go wrong.
baray98
Bookmarks