By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,330 Members | 1,425 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,330 IT Pros & Developers. It's quick & easy.

Memory DeAllocation

P: 3
hi
i declared a structure as shown below
Struct Name
{
int *nPtr;
float *fPtr;
}

In MFC, one command button click event, i added the following code and CDocClass has the structure as a member variable
Name *str;

In constructor it is initialized to NULL
str = NULL
CDocClass::OnButtonClicked()
{
if(str)
{
delete nPtr;
delete fPtr;
nPtr = NULL;
fPtr = NULL;
delete str;
str = NULL;
}
str = new name[1000]; //This size may varry during run time, instead a constant number i used one more variable to represent the array of memory block..
nPtr = new int[1000];
fPtr = new float[100];
....
....
}
here the memory is released in Release build of the MFC code. but not deallocated in the Debug build.
even i used the following for deletion
if(str)
{
delete [] nPtr;
delete [] fPtr;
nPtr = NULL;
fPtr = NULL;
delete [] str;
str = NULL;
}
i couldn't guess the reason for this problem??!!!!
i have used the Virtual memory size in the "Task Manager" for the memroy allocation and deallocation,
In release and debug build it increaes when i allocate memory..
In release build, the virtual memory size decrease when i delete the pointers..
but this didn't happen in Debug build..
can anybody help me to figure out the reeason????
Mar 13 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.