Destructors not invoked -> Memory leaks
-
I've built an SDI application without problems, adding classes. When I've linked a thirdy party library i've had to change compiler switch from Multithreaded (/MT) to Multithreaded DLL (/MD) and adding the _AFXDLL symbol to properly compile the entire project. The project is linked with the shard version of MFC. When the application exits, i've noticed a lot of memory leaks and that classes destructors are not invoked (CView derived class and CMainFrame destructors are invoked, but CDocument destructor and other classes destructors are not invoked). I can't understand the causes of this problem and if the /MD compiler option is one of them. Any idea ?
-
I've built an SDI application without problems, adding classes. When I've linked a thirdy party library i've had to change compiler switch from Multithreaded (/MT) to Multithreaded DLL (/MD) and adding the _AFXDLL symbol to properly compile the entire project. The project is linked with the shard version of MFC. When the application exits, i've noticed a lot of memory leaks and that classes destructors are not invoked (CView derived class and CMainFrame destructors are invoked, but CDocument destructor and other classes destructors are not invoked). I can't understand the causes of this problem and if the /MD compiler option is one of them. Any idea ?
Take a look at where and how you create an instance of the class. The probable cause is that you have created an instance somewhere with the keyword new, and you are failing to call delete. If that class has other classes as members, their destructors will in turn fail to be called.