加载和免费库时内存泄漏 [英] Memory leak while load and free library

查看:81
本文介绍了加载和免费库时内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在连续加载和释放库时发现内存泄漏。

当我看到任务管理器时,内存会为这个应用程序而长大。我的DLLMain中没有内存分配。这是示例代码



for(int i = 0; i< 500; i ++)

{

hInstance = LoadLibrary(MySampleDLL.dll);

if(hInstance!= NULL)

{

FreeLibrary(hInstance);

hInstance = NULL;

}

}

I found a memory leak while loading and freeing library contnuously.
When I see the task manager, the memory grow up for this application. I have no memory allocation in my DLLMain. This is the sample code

for (int i=0;i<500;i++)
{
hInstance = LoadLibrary("MySampleDLL.dll");
if (hInstance !=NULL)
{
FreeLibrary(hInstance);
hInstance = NULL;
}
}

推荐答案

首先,不信任任务管理器,这是一个非常不准确的证据。它显示的可能不是实时泄漏。



但如果你真的害怕实时泄漏,不要采取改变;考虑使用一些名为内存调试器的产品。请特别注意:

http://en.wikipedia.org/wiki/Memory_debugger [ ^ ]。



-SA
First of all, don't trust Task Manager, it's a very inaccurate evidence. What it shows may be not a real time leak.

But if you really afraid of real time leak, don't take changes; consider using some of the products called memory debuggers. Please see, in particular:
http://en.wikipedia.org/wiki/Memory_debugger[^].

—SA


这篇关于加载和免费库时内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆