I am facing the problem of memory leak. In one of the application I am taking dynamic global object. And when I try to delete then in my WinMain() function before return 0; statement but it gives me assertion errror.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
The memory leak control implemented on the CRT overloads the new and delete operators to add some extra memory to contain some signatures that are tracked by a global data structure.
At end, is something is wrong between this structure and the related allocated memory a warning is reported.
In your case your obj pointer is also a global data. But since the initialization order of global data is not predictable (in the sense that it depends on the order the linker links the modules) probably your "new" call happens before the tracking structure is properly initialized (hence, it isn't tracked).
But the delete is. Hence the misleading and the resulting report.
Now allocation and deallocation are wrapped in ctor / dtor.
When thehandle is created the compiler will place an "atexit" to invoke the destructor.
Since the order of destruction is the inverse of the order of construction, you're so granted that either both new and delete are tracked or none of them is. Both case are coherent.
I see just now ThatsAlok writing "use auto_ptr".
In fact std::auto_ptr behave just like myhandle in respect to construction / destruction.
Your program is not causing any assertion, but the following is. May be you are doing something like this -
p = new char;
myclass *obj = new myclass();
myclass *obj2 = new myclass();
The message i am getting is p[osted here.Please help what should i do to get rid of this error:
>Deleting intermediate and output files for project 'AudioCap', configuration 'Debug|Win32'
1>Performing Custom Build Step
1>MC: -u switch must be used with Unicode message file!
1>Project : error PRJ0019: A tool returned an error code from "Performing Custom Build Step"
1>Build log was saved at "file://d:\voice editor sw\VRS\AudioCap\Debug\BuildLog.htm"
1>AudioCap - 1 error(s), 0 warning(s)
MC: -u switch must be used with Unicode message file!
May be your project settings are ANSI, and you are using switch -u which is for unicode files. Use -a in place of -u.
Or paste the "Custom build step" steps. Also tell about your project settings, ANSI or UNICODE ?
I have list control whose property is set to
WS_BORDER | WS_TABSTOP,293,37,146,214,
WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_RIGHT |
Am displaying the data read from the serial port in the list control but there is lot of filckering.Below is the code to display the data in list control.Is there any thing am missing in the code.Why there is flickering?More flickering starts when i start deleting the data.If i don't delete i get assert error that maybe due to memory overflow of the list control.Plz help me out.
void CNgpptDialog::ReadSerialData(CString sIn)
int counter = ptrCmdResp->GetItemCount();
ptrCmdResp->InsertItem(counter, "");// to insert a row
ptrCmdResp->SetItemText(counter, 0, pressure_data);// column0
ptrCmdResp->EnsureVisible(counter, FALSE); // Scrolls downwords.
if(counter > 150)// I start deleting first data when the number of items in the list control is > 150
int nIndex = ptrCmdResp->GetItemCount();
Thanks in advance
Last Visit: 31-Dec-99 18:00 Last Update: 2-Aug-21 6:44