473,320 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Memory DeAllocation

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
0 1591

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

Similar topics

5
by: Khalid | last post by:
II am allocating alot of memory for my problem model which uses stl containers for these pointers, will stl free the memory? by other words what is the semantics of memory ownership in stl? ...
1
by: qazmlp | last post by:
Is there a memory leak here? Can't the memory deallocation happen automatically as the std::string object anyway is owning the memory? #include <cstring> #include <string> #include <iostream> ...
4
by: Franklin Lee | last post by:
Hi All, I use new to allocate some memory,even I doesn't use delete to release them. When my Application exit, OS will release them. Am I right? If I'm right, how about Thread especally on...
2
by: Manisha | last post by:
Hi, I am creating a C++ dll which is used to process data passed to it through one of its exported functions. It should be able to process 160 simultaneous requests. For this reason, I have...
11
by: aaaaa | last post by:
Hi all, Does anybody know if STLPort or SGI STL standard allocators do memory pooling for the list, map and set? Also I have had a look at the BOOST pool_alloc (to be used as a pooling...
2
by: lovecreatesbeauty | last post by:
Hello experts, When I allocate memory use malloc() and forget to call a corresponding free(), does this allocated memory lose forever after program exits (Can i regard it same as process...
4
by: hazz | last post by:
given namespace WindowsService1 { public class Service1 : System.ServiceProcess.ServiceBase......... private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { ArrayList...
6
by: madhu | last post by:
vector<vector<vector<long Vector3D; // 3dvector. for (long k = 0; j < Depth; j++ ) { Vector3D.push_back ( vector<vector<A_Type() ); for (long j = 0; j < Height; j++ ) { Vector3D.push_back (...
18
by: happyvalley | last post by:
Hi, basically, the test function get a char pointer, and assigned a string to it. then the string is passed back by the call-by-reference mechanism. in test(), I reallocate some memory for the...
9
by: Steven Powers | last post by:
Imagine the following setup class Parent { virtual void doStuff(); } class Child : public Parent { virtual void doStuff(); }
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.