Because many MDI child windows can come and go during a program's execution, it is important to define a function for your MDI child window class that cleans up any memory used by the window when it is closed. For main frame windows, this is less important since there is typically only one frame window per application and the memory allocated by that window is automatically freed by Windows when the application terminates.
You can respond to the WM_NCDESTROY message to free resources and memory used by your MDI child window since this message is the last message that the window receives before it is destroyed. To handle the WM_NCDESTROY message, you can define the OnNcDestroy message-handler function for your MDI child window class and include the ON_WM_NCDESTROY macro in your message map.