现象:调用一个第三方库的dll,即使调用一个空函数,也会检测到内存泄漏。

原因:【英文转自https://blog.csdn.net/crybird/article/details/80907192】
MFC dumps leaks prematurely when it exits, instead of waiting for the
CRT to dump leaks following static data destruction, and this causes
spurious leak reports for objects which allocated memory before MFC
was initialized and which thus are destroyed after MFC exits. This is
commonly observed when using the MFC DLL in a program that also uses
the C++ runtime DLL.
就是说全局静态对象的析构是在内存泄漏检测机制之后进行的,所以对它来说,这些全局变量就是没有释放内存。

解决方案:用#pragma comment(lib, “xxx.lib”)来替代项目属性->l连接器->附加依赖项的添加。