ApplicationVerifier 未检测到句柄泄漏,我该怎么办?
我确实正确选择了可执行文件,因为我可以让它响应我所做的某些事情。 但我无法让 ApplicationVerifier 正确检测句柄泄漏。
这是一个示例:
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
HANDLE hFile = CreateFile(_T("C:\\test.txt"), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
return 0;
}
ApplicationVerifier 不会检测到这一点。
我该怎么做才能检测到上述问题?
I did select the executable correctly, because I can get it to respond to certain things I do. But I can't get ApplicationVerifier to properly detect a handle leak.
Here is an example:
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
HANDLE hFile = CreateFile(_T("C:\\test.txt"), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
return 0;
}
ApplicationVerifier doesn't detect this.
What can I do to detect the above problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码是否仅通过 CreateFile 创建句柄? 如果是这样,您可以将这些方法宏化为执行自定义实现的泄漏检测的版本。 这是很多工作,但它会完成工作。
在程序结束时,您需要调用 CheckForLeaks。 就像我说的,虽然工作量很大,但它可能对你的场景有所帮助。
Is your code only creating handles through CreateFile? If so you can just macro these methods out to versions that do custom implemented leak detection. It's a lot of work but it will get the job done.
At the end of your program you'd need to call CheckForLeaks. Like I said though, quite a bit of work but it may help with your scenairo.