wxwindows MDI Eg: clarification
Posted: Sat Sep 11, 2004 8:40 pm
Hi,
I was going through the example MDI program
( in $WXDIR/samples/mdi directory).
<-- Begin code fragment -->
void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) )
{
// Make another frame, containing a canvas
MyChild *subframe = new MyChild(frame, _T("Canvas Frame"),
wxPoint(-1, -1), wxSize(-1, -1),
wxDEFAULT_FRAME_STYLE);
.
.
subframe->Show(TRUE);
}
<-- End code fragment -->
We are allocating memory for subframe here. ( of type MyChild).
But we are not freeing it. When would it be freed ?
If I were to close the document window corresponding to this MDI Child Frame, would this memory be freed ?
If not, how would prevent a probably memory leak in this example .
Assume I invoke this function N number of times, would i be leaving behind a memory leak every time the function is invoked (assume, I close the windows after invocation manually ).
-- Karthik.
PS: I had posted this previously to comp.soft-sys.wxwindows . Since I did not get any reply there, I am posting it here. Sorry if you feel this is cross-posting
I was going through the example MDI program
( in $WXDIR/samples/mdi directory).
<-- Begin code fragment -->
void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) )
{
// Make another frame, containing a canvas
MyChild *subframe = new MyChild(frame, _T("Canvas Frame"),
wxPoint(-1, -1), wxSize(-1, -1),
wxDEFAULT_FRAME_STYLE);
.
.
subframe->Show(TRUE);
}
<-- End code fragment -->
We are allocating memory for subframe here. ( of type MyChild).
But we are not freeing it. When would it be freed ?
If I were to close the document window corresponding to this MDI Child Frame, would this memory be freed ?
If not, how would prevent a probably memory leak in this example .
Assume I invoke this function N number of times, would i be leaving behind a memory leak every time the function is invoked (assume, I close the windows after invocation manually ).
-- Karthik.
PS: I had posted this previously to comp.soft-sys.wxwindows . Since I did not get any reply there, I am posting it here. Sorry if you feel this is cross-posting