dll中的内存泄漏问题,高手来帮忙!

stevenying 2003-12-12 10:33:05
我用BoundsChecker检查我的程序;
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
// Remove this if you use lpReserved
UNREFERENCED_PARAMETER(lpReserved);

if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("HOOKS.DLL Initializing!\n");

// Extension DLL one-time initialization
if (!AfxInitExtensionModule(HooksDLL, hInstance))
return 0;

// Insert this DLL into the resource chain
// NOTE: If this Extension DLL is being implicitly linked to by
// an MFC Regular DLL (such as an ActiveX Control)
// instead of an MFC application, then you will want to
// remove this line from DllMain and put it in a separate
// function exported from this Extension DLL. The Regular DLL
// that uses this Extension DLL should then explicitly call that
// function to initialize this Extension DLL. Otherwise,
// the CDynLinkLibrary object will not be attached to the
// Regular DLL's resource chain, and serious problems will
// result.

new CDynLinkLibrary(HooksDLL);// <<<=========指在这里内存泄漏!!!!!
glhInstance = hInstance;
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("HOOKS.DLL Terminating!\n");
// Terminate the library before destructors are called
AfxTermExtensionModule(HooksDLL);
}
return 1; // ok
}

请问为什么,谢谢
...全文
96 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
会思考的草 2003-12-16
  • 打赏
  • 举报
回复
Boundschecker的工作原理是类似于APIhook的东西,他用自己的dll嵌入到你的程序中,监视每一个new操作有没有对应的delete操作,但是如果你是在当前模块new,但是在另一个模块delete,它就会误以为你没有delete。
boundschecker总会有这几个错误报告的,不用管它。
bluebohe 2003-12-12
  • 打赏
  • 举报
回复
BoundsChecker总会检查出这个内存泄漏的,你应该是用他检查你自己的代码而不是别人的,如果你添加一段代码后BoundsChecker报告新的内存泄漏问题,你就要注意了
EricTangHL 2003-12-12
  • 打赏
  • 举报
回复
防止内存泄露也是我的工作重点。
azs 2003-12-12
  • 打赏
  • 举报
回复
没关系,
原因是内存有分配,但没释放,
可以不释放,因为进程结束,系统会清除这部分内存的占用
HanZhu1 2003-12-12
  • 打赏
  • 举报
回复
看看CDynLinkLibrary 的构造函数
checkyvc6 2003-12-12
  • 打赏
  • 举报
回复
这没有什么,工具比不过人脑,她认为有问题是因为她不够智能化,不知道他会自动delete掉的
stevenying 2003-12-12
  • 打赏
  • 举报
回复
啊,为什么呢?
ISunwu 2003-12-12
  • 打赏
  • 举报
回复
没关系的,不要管他。
stevenying 2003-12-12
  • 打赏
  • 举报
回复
up
popyyb 2003-12-12
  • 打赏
  • 举报
回复
mark

15,473

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧