UpdateData - Out Of Memory - Serious problem
-
Hello, I have a SDI application for Win CE ARMV4I. From menu, I select an option & a dialog appreas which is a main dialog. On this dialog, other child dialogs are opened. Their are 7 instances of child dialogs. On a message command send by a child dialog, the previous dialog is destroyed, new is created & displayed. On Child dialog 1, on the below lines:
AfxMessageBox(\_T("Into OnGetData")); UpdateData(true); OperatorDetails od; if (true) { m\_operName = "Trial"; UpdateData (false); AfxMessageBox(m\_operName); EnableConfirm(true); } else { m\_operName = ""; EnableConfirm(false); } od.~OperatorDetails(); UpdateData (true);
On above code in UpdateData, I get "ASsertionFailure" File dlgdata.cpp: line 52 error, I choose Retry/Ignore (Abort shuts down the window) & I get "An unsupported operation was attempted". I get this error 3 times when I am at the above lines, later it is again fine. The flow of error windows is like "Into OnGetData", "Assertion Failure", "An unsuported...", "Assertion Failure", "An unsuported...", "Trial", "Assertion Failure" & "An unsuported...". The error is not with EnableConfirm(), as I tried deleting the lines but the error still persists. On coming of Child 2, I get "Out Of Memory" Error. Can anyone tell me what is the error and why does this come like this. Any help is highly appreciated.
Thanks Terry
-
Hello, I have a SDI application for Win CE ARMV4I. From menu, I select an option & a dialog appreas which is a main dialog. On this dialog, other child dialogs are opened. Their are 7 instances of child dialogs. On a message command send by a child dialog, the previous dialog is destroyed, new is created & displayed. On Child dialog 1, on the below lines:
AfxMessageBox(\_T("Into OnGetData")); UpdateData(true); OperatorDetails od; if (true) { m\_operName = "Trial"; UpdateData (false); AfxMessageBox(m\_operName); EnableConfirm(true); } else { m\_operName = ""; EnableConfirm(false); } od.~OperatorDetails(); UpdateData (true);
On above code in UpdateData, I get "ASsertionFailure" File dlgdata.cpp: line 52 error, I choose Retry/Ignore (Abort shuts down the window) & I get "An unsupported operation was attempted". I get this error 3 times when I am at the above lines, later it is again fine. The flow of error windows is like "Into OnGetData", "Assertion Failure", "An unsuported...", "Assertion Failure", "An unsuported...", "Trial", "Assertion Failure" & "An unsuported...". The error is not with EnableConfirm(), as I tried deleting the lines but the error still persists. On coming of Child 2, I get "Out Of Memory" Error. Can anyone tell me what is the error and why does this come like this. Any help is highly appreciated.
Thanks Terry
My first suggestion would be to not use
UpdateData()
."Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Hello, I have a SDI application for Win CE ARMV4I. From menu, I select an option & a dialog appreas which is a main dialog. On this dialog, other child dialogs are opened. Their are 7 instances of child dialogs. On a message command send by a child dialog, the previous dialog is destroyed, new is created & displayed. On Child dialog 1, on the below lines:
AfxMessageBox(\_T("Into OnGetData")); UpdateData(true); OperatorDetails od; if (true) { m\_operName = "Trial"; UpdateData (false); AfxMessageBox(m\_operName); EnableConfirm(true); } else { m\_operName = ""; EnableConfirm(false); } od.~OperatorDetails(); UpdateData (true);
On above code in UpdateData, I get "ASsertionFailure" File dlgdata.cpp: line 52 error, I choose Retry/Ignore (Abort shuts down the window) & I get "An unsupported operation was attempted". I get this error 3 times when I am at the above lines, later it is again fine. The flow of error windows is like "Into OnGetData", "Assertion Failure", "An unsuported...", "Assertion Failure", "An unsuported...", "Trial", "Assertion Failure" & "An unsuported...". The error is not with EnableConfirm(), as I tried deleting the lines but the error still persists. On coming of Child 2, I get "Out Of Memory" Error. Can anyone tell me what is the error and why does this come like this. Any help is highly appreciated.
Thanks Terry
Terry,
Trupti Mehta wrote:
On above code in UpdateData, I get "ASsertionFailure" File dlgdata.cpp: line 52 error, I choose Retry/Ignore
Could you get me the call stack? Press "retry" and it will take you to debugger. Just press "Alt+7" and you can see the Call stack window.
Trupti Mehta wrote:
On coming of Child 2, I get "Out Of Memory" Error.
Since its WinCE, memory is limited. Check whether your dialog objects are created in heap instead of stack. Recursive function calls too can cause "out of memory". Check your call stack and verify that. OT: Did you checked my reply in your old parent-child dialog communication problem? Regards, Jijo.
_____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.
-
Terry,
Trupti Mehta wrote:
On above code in UpdateData, I get "ASsertionFailure" File dlgdata.cpp: line 52 error, I choose Retry/Ignore
Could you get me the call stack? Press "retry" and it will take you to debugger. Just press "Alt+7" and you can see the Call stack window.
Trupti Mehta wrote:
On coming of Child 2, I get "Out Of Memory" Error.
Since its WinCE, memory is limited. Check whether your dialog objects are created in heap instead of stack. Recursive function calls too can cause "out of memory". Check your call stack and verify that. OT: Did you checked my reply in your old parent-child dialog communication problem? Regards, Jijo.
_____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.
Jijo raj wrote:
Could you get me the call stack? Press "retry" and it will take you to debugger. Just press "Alt+7" and you can see the Call stack window.
That's the problem Jijo, I don't get any stack. It infact doesn't go to the debugger. Usually on errors/exceptions the file where the error rises comes up & we can debug it, but with this error that file doesn't come up only. Also Alt+7 on Retry didn't work. Immediately after pressing Retry, "An unsupported operations ..." message box comes up. <blockquote class="FQ"><div class="FQA">Jijo raj wrote:</div>OT: Did you checked my reply in your old parent-child dialog communication problem? </blockquote> Yes I did. As I don't call the child dialogs by DoModal(), but call by Create & then ShowWindow(). This is the way they are created & called: In parent .cpp:
void DataEntryDialog::CreateChildDialogs() // CALLED IN OnInitDialog()....
{
CRect rect(4, 2, 5,2);childPage1.CRHCreateGenericChildDialog(this, &rect,IDD\_PAGE1\_DLG, NULL); childPage1.SetDeptStock(deptStock); childPage1.ShowWindow(SW\_SHOW); childVisible = 1; free(rect); return;
}
In child, while finishing work with it :
CPage1Dlg::~CPage1Dlg() {
m_operName.Empty(); // CString
deptStock.~DeptStock(); // Object
// operatorsMap->RemoveAll(); // CMap
delete operatorsMap; // CMap*// this->DestroyWindow();
}void CPage1Dlg::TellParent()
{
// AfxMessageBox(_T("Inside TellPArent"));// Update deptStock obj with the parent this->CRHPostMessageToParent(WM\_CHANGED\_DS, (int)&deptStock); this->ShowWindow(SW\_HIDE); this->CRHPostMessageToParent(WM\_SHOW\_NEXT\_VIEW, 2);
// AfxMessageBox(_T("Finished TellParent"));
return;
}
Back to parent, in OnSHOW_NEXT_VIEW MESSAGE:
afx_msg LRESULT DataEntryDialog::OnSHOW_NEXT_VIEW(WPARAM wparam, LPARAM lparam) {
// AfxMessageBox(_T("Going to sHOW Page 2 "));
int childView = (int)lparam; DestroyVisibleChild(); CRect rect(4, 2, 5,2); switch(childView) { case 1: childPage1.CRHCreateGenericChildDialog(this, &rect,IDD\_PAGE1\_DLG, NULL); childPage1.SetDeptStock(deptStock); childPage1.SetOperatorsMap(operMap); childPage1.ShowWindow(SW\_SHOW); break; case 2: // Page 2 AfxMessageBox(\_T("ABOUT Create Child 2")); childPage2.CRHCreateGenericChildDialog(this, &rect, IDD\_PAGE2\_DLG, NULL); childPage2.SetDeptSt
-
Hello, I have a SDI application for Win CE ARMV4I. From menu, I select an option & a dialog appreas which is a main dialog. On this dialog, other child dialogs are opened. Their are 7 instances of child dialogs. On a message command send by a child dialog, the previous dialog is destroyed, new is created & displayed. On Child dialog 1, on the below lines:
AfxMessageBox(\_T("Into OnGetData")); UpdateData(true); OperatorDetails od; if (true) { m\_operName = "Trial"; UpdateData (false); AfxMessageBox(m\_operName); EnableConfirm(true); } else { m\_operName = ""; EnableConfirm(false); } od.~OperatorDetails(); UpdateData (true);
On above code in UpdateData, I get "ASsertionFailure" File dlgdata.cpp: line 52 error, I choose Retry/Ignore (Abort shuts down the window) & I get "An unsupported operation was attempted". I get this error 3 times when I am at the above lines, later it is again fine. The flow of error windows is like "Into OnGetData", "Assertion Failure", "An unsuported...", "Assertion Failure", "An unsuported...", "Trial", "Assertion Failure" & "An unsuported...". The error is not with EnableConfirm(), as I tried deleting the lines but the error still persists. On coming of Child 2, I get "Out Of Memory" Error. Can anyone tell me what is the error and why does this come like this. Any help is highly appreciated.
Thanks Terry
It seems to me direct call of destructor (
od.~OperatorDetails()
and so on) is very bad technique ((( -
My first suggestion would be to not use
UpdateData()
."Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
David, not to use UpdateData, then what to use? Go for something like SetWindowText()! What is the associated var is not of CString & of other data type like int, float, etc. Would be glad to know the alternative. More would also like to know why not to use UpdateData ?
Thanks Terry
-
It seems to me direct call of destructor (
od.~OperatorDetails()
and so on) is very bad technique (((Artem Kustikov wrote:
It seems to me direct call of destructor (od.~OperatorDetails() and so on) is very bad technique (((
Then what technique to use? free(&obj); obj.~Objct(); I don't get any error or exception no, or stack. On retry it immediately shows "An unsupported operation was attempted". Alt+7 also doesn't work. I am not able to debug or give breakpoints with CE & eVC++4. If their is a way to work out, let me know. To figure out such errors, I always opt for debugging only.
Thanks Terry
-
David, not to use UpdateData, then what to use? Go for something like SetWindowText()! What is the associated var is not of CString & of other data type like int, float, etc. Would be glad to know the alternative. More would also like to know why not to use UpdateData ?
Thanks Terry
Trupti Mehta wrote:
David, not to use UpdateData, then what to use?
See here.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Jijo raj wrote:
Could you get me the call stack? Press "retry" and it will take you to debugger. Just press "Alt+7" and you can see the Call stack window.
That's the problem Jijo, I don't get any stack. It infact doesn't go to the debugger. Usually on errors/exceptions the file where the error rises comes up & we can debug it, but with this error that file doesn't come up only. Also Alt+7 on Retry didn't work. Immediately after pressing Retry, "An unsupported operations ..." message box comes up. <blockquote class="FQ"><div class="FQA">Jijo raj wrote:</div>OT: Did you checked my reply in your old parent-child dialog communication problem? </blockquote> Yes I did. As I don't call the child dialogs by DoModal(), but call by Create & then ShowWindow(). This is the way they are created & called: In parent .cpp:
void DataEntryDialog::CreateChildDialogs() // CALLED IN OnInitDialog()....
{
CRect rect(4, 2, 5,2);childPage1.CRHCreateGenericChildDialog(this, &rect,IDD\_PAGE1\_DLG, NULL); childPage1.SetDeptStock(deptStock); childPage1.ShowWindow(SW\_SHOW); childVisible = 1; free(rect); return;
}
In child, while finishing work with it :
CPage1Dlg::~CPage1Dlg() {
m_operName.Empty(); // CString
deptStock.~DeptStock(); // Object
// operatorsMap->RemoveAll(); // CMap
delete operatorsMap; // CMap*// this->DestroyWindow();
}void CPage1Dlg::TellParent()
{
// AfxMessageBox(_T("Inside TellPArent"));// Update deptStock obj with the parent this->CRHPostMessageToParent(WM\_CHANGED\_DS, (int)&deptStock); this->ShowWindow(SW\_HIDE); this->CRHPostMessageToParent(WM\_SHOW\_NEXT\_VIEW, 2);
// AfxMessageBox(_T("Finished TellParent"));
return;
}
Back to parent, in OnSHOW_NEXT_VIEW MESSAGE:
afx_msg LRESULT DataEntryDialog::OnSHOW_NEXT_VIEW(WPARAM wparam, LPARAM lparam) {
// AfxMessageBox(_T("Going to sHOW Page 2 "));
int childView = (int)lparam; DestroyVisibleChild(); CRect rect(4, 2, 5,2); switch(childView) { case 1: childPage1.CRHCreateGenericChildDialog(this, &rect,IDD\_PAGE1\_DLG, NULL); childPage1.SetDeptStock(deptStock); childPage1.SetOperatorsMap(operMap); childPage1.ShowWindow(SW\_SHOW); break; case 2: // Page 2 AfxMessageBox(\_T("ABOUT Create Child 2")); childPage2.CRHCreateGenericChildDialog(this, &rect, IDD\_PAGE2\_DLG, NULL); childPage2.SetDeptSt
Terry, I can see a chance of serious synchronization error. Your
UpdateData()
is called after sending notification to the parent? In that case, your child dialog will get deleted by parent dialog and after deletion you might be callingUpdateData()
which will endup in assertion from MFC. Its a wild guess, since i don't have the full picture of your code.Trupti Mehta wrote:
i have a practise of calling just dd.~DeptDetails(), but someone pointed out, "Calling destructor without freeing the memory", so where am I going wrong. And keeping that in mind, in many such places I have called free(&dd) before the destructor.
As per C++ standards, you can call destructor only if the object is allocated by
placement new
. http://weseetips.com/2008/04/01/construct-c-objects-at-predefined-memory-locations/[^]. But i am not sure, whether its legal in WinCE where rules are different.Trupti Mehta wrote:
t present I pass object via parent & update the parent back by CHANGED_DS message. Is their any better way to work out which might reduce sending msg to parent for updated object.
Keep DeptStock as a member of parent and Let the child windows keep a reference to your DeptStock and update that. When the parent window create you child window, pass DeptStock as constructor parameter by reference. So the child dialog can keep a reference to it. So that you can directly modify the DeptStock, by being in the child dialog itself and can avoid that message updating mechanism. You can also use pointers. Feel free to ask any doubts, and i'll try to help with my limited knowledge. :rolleyes: Regards, Jijo.
_____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.
-
Terry, I can see a chance of serious synchronization error. Your
UpdateData()
is called after sending notification to the parent? In that case, your child dialog will get deleted by parent dialog and after deletion you might be callingUpdateData()
which will endup in assertion from MFC. Its a wild guess, since i don't have the full picture of your code.Trupti Mehta wrote:
i have a practise of calling just dd.~DeptDetails(), but someone pointed out, "Calling destructor without freeing the memory", so where am I going wrong. And keeping that in mind, in many such places I have called free(&dd) before the destructor.
As per C++ standards, you can call destructor only if the object is allocated by
placement new
. http://weseetips.com/2008/04/01/construct-c-objects-at-predefined-memory-locations/[^]. But i am not sure, whether its legal in WinCE where rules are different.Trupti Mehta wrote:
t present I pass object via parent & update the parent back by CHANGED_DS message. Is their any better way to work out which might reduce sending msg to parent for updated object.
Keep DeptStock as a member of parent and Let the child windows keep a reference to your DeptStock and update that. When the parent window create you child window, pass DeptStock as constructor parameter by reference. So the child dialog can keep a reference to it. So that you can directly modify the DeptStock, by being in the child dialog itself and can avoid that message updating mechanism. You can also use pointers. Feel free to ask any doubts, and i'll try to help with my limited knowledge. :rolleyes: Regards, Jijo.
_____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.
Jijo raj wrote:
I can see a chance of serious synchronization error. Your UpdateData() is called after sending notification to the parent? In that case, your child dialog will get deleted by parent dialog and after deletion you might be calling UpdateData() which will endup in assertion from MFC. Its a wild guess, since i don't have the full picture of your code.
No Jijo, after finishing all taks only communicating with the parent happens. On user clicks to "Yes" button only the child communicates with the parent. The child1 has a text box, user enters in it & clicks on "Get Data" btn, on that click :
Thanks Terry
-
Terry, I can see a chance of serious synchronization error. Your
UpdateData()
is called after sending notification to the parent? In that case, your child dialog will get deleted by parent dialog and after deletion you might be callingUpdateData()
which will endup in assertion from MFC. Its a wild guess, since i don't have the full picture of your code.Trupti Mehta wrote:
i have a practise of calling just dd.~DeptDetails(), but someone pointed out, "Calling destructor without freeing the memory", so where am I going wrong. And keeping that in mind, in many such places I have called free(&dd) before the destructor.
As per C++ standards, you can call destructor only if the object is allocated by
placement new
. http://weseetips.com/2008/04/01/construct-c-objects-at-predefined-memory-locations/[^]. But i am not sure, whether its legal in WinCE where rules are different.Trupti Mehta wrote:
t present I pass object via parent & update the parent back by CHANGED_DS message. Is their any better way to work out which might reduce sending msg to parent for updated object.
Keep DeptStock as a member of parent and Let the child windows keep a reference to your DeptStock and update that. When the parent window create you child window, pass DeptStock as constructor parameter by reference. So the child dialog can keep a reference to it. So that you can directly modify the DeptStock, by being in the child dialog itself and can avoid that message updating mechanism. You can also use pointers. Feel free to ask any doubts, and i'll try to help with my limited knowledge. :rolleyes: Regards, Jijo.
_____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.
<blockquote class="FQ"><div class="FQA">Jijo raj wrote:</div>I can see a chance of serious synchronization error. Your UpdateData() is called after sending notification to the parent? In that case, your child dialog will get deleted by parent dialog and after deletion you might be calling UpdateData() which will endup in assertion from MFC. Its a wild guess, since i don't have the full picture of your code.</blockquote> No Jijo, after finishing all taks only communicating with the parent happens. On user clicks to "Yes" button only the child communicates with the parent. The child1 has a text box, user enters in it & clicks on "Get Data" btn, on that click :
void CPage1Dlg::OnGetData()
{
AfxMessageBox(_T("Into OnGetData"));
UpdateData(true);// Search operator no OperatorDetails od;
// if (operatorsMap->Lookup(m_number, od) != 0) { // Found operator number
// m_operName = od.GetOperName();if (true) { m\_operName = "Trial"; UpdateData (false); AfxMessageBox(m\_operName); EnableConfirm(true); } else { m\_operName = ""; EnableConfirm(false); } od.~OperatorDetails(); UpdateData (true); return;
}
// Enables /Disables the Confirm Y/N? & Yes,No buttons
void CPage1Dlg::EnableConfirm(bool enable)
{
if (enable) {
GetDlgItem(IDC_NAME_BTN)->ShowWindow(false);
GetDlgItem(IDC_CONFIRM_LABEL)->ShowWindow(true);
GetDlgItem(IDC_YES1_BTN)->ShowWindow(true);
GetDlgItem(IDC_WRONG_BTN)->ShowWindow(true);
} else {
GetDlgItem(IDC_NAME_BTN)->ShowWindow(true);
GetDlgItem(IDC_CONFIRM_LABEL)->ShowWindow(false);
GetDlgItem(IDC_YES1_BTN)->ShowWindow(false);
GetDlgItem(IDC_WRONG_BTN)->ShowWindow(false);
}
}Then the user has to click Yes or No button. On No, the focus again return to the text box & on yes:
void CPage1Dlg::OnYes()
{
// Create object of OperatorDetails with provided info
OperatorDetails* odet(m_number, m_operName);
// Update the DeptStock
deptStock.SetOperator(odet);
// Free up the memory of OpertatorDetails
free(&odet);
odet.~OperatorDetails();// Communicate with the Parent TellParent(); return;
}
void CPage1Dlg::TellParent()
{
// AfxMessageBox(_T("Inside TellPArent"));// Update deptStock obj with the parent this->CRHPostMessageToParent(WM\_CHANGED\_DS, (int)&deptStock); this->ShowWindow(SW\_HIDE); this->CRHPostMessageToParent(WM\_SHOW\_NEXT\_VIEW, 2);
// AfxMessageBox(_T("Finished TellParent"));
return;
}
-
Terry, I can see a chance of serious synchronization error. Your
UpdateData()
is called after sending notification to the parent? In that case, your child dialog will get deleted by parent dialog and after deletion you might be callingUpdateData()
which will endup in assertion from MFC. Its a wild guess, since i don't have the full picture of your code.Trupti Mehta wrote:
i have a practise of calling just dd.~DeptDetails(), but someone pointed out, "Calling destructor without freeing the memory", so where am I going wrong. And keeping that in mind, in many such places I have called free(&dd) before the destructor.
As per C++ standards, you can call destructor only if the object is allocated by
placement new
. http://weseetips.com/2008/04/01/construct-c-objects-at-predefined-memory-locations/[^]. But i am not sure, whether its legal in WinCE where rules are different.Trupti Mehta wrote:
t present I pass object via parent & update the parent back by CHANGED_DS message. Is their any better way to work out which might reduce sending msg to parent for updated object.
Keep DeptStock as a member of parent and Let the child windows keep a reference to your DeptStock and update that. When the parent window create you child window, pass DeptStock as constructor parameter by reference. So the child dialog can keep a reference to it. So that you can directly modify the DeptStock, by being in the child dialog itself and can avoid that message updating mechanism. You can also use pointers. Feel free to ask any doubts, and i'll try to help with my limited knowledge. :rolleyes: Regards, Jijo.
_____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.
Jijo raj wrote:
Keep DeptStock as a member of parent and Let the child windows keep a reference to your DeptStock and update that. When the parent window create you child window, pass DeptStock as constructor parameter by reference. So the child dialog can keep a reference to it. So that you can directly modify the DeptStock, by being in the child dialog itself and can avoid that message updating mechanism. You can also use pointers.
Thanks jijo, this helped me reduce 1 message to the parent & solved out of memory problem. Based on your info reg. calling destructors, I studied over it & removed all lines wher I have unnecessarily explicitly call the destructor. This helped, but Still Assertion Failed continues. In fact on ending the child1 & showing child2, i get error message based on wincore lib. Child 2 is visible but the error keeps on coming for some time & then again normal. It seems like something is uncompatible or am doing it wrongly. Can I pass you the code, so you can help me much better. Please let me know how do I send you the parent & child file. Please help me.
Thanks Terry