问题描述
这小段简单的代码出现,表明在用于搜索蓝牙设备时WASLookupServiceBegin中存在内存泄漏.如果您运行代码并监视"Mem Usage",在任务管理器中,该值增加.同样,如果您监视私有字节"
此代码是使用VS 2008编译的.是否有人遇到过这个问题,或者有人可以建议我的代码示例在哪里不正确.
WSAQUERYSET querySet;
内存集(& querySet,0,sizeof(querySet));
querySet.dwSize = sizeof(querySet);
querySet. dwNameSpace = NS_BTH;
HANDLE hLookup;
DWORD标志= LUP_CONTAINERS;
for(int loop = 0; loop< 32766; loop ++)
{
int result = WSALookupServiceBegin(& querySet,flags& hLookup);
如果(0 ==结果)
{
printf("WSALookupServiceBegin()-好的循环:%d \ n",循环);
结果= WSALookupServiceEnd(hLookup);
}
其他
{
printf("WSALookupServiceBegin()-错误:%s.循环:%d \ n",GetLastErrorMessage(GetLastError()),循环);
}
}
This small simple piece of code appears to show there is a memory leak in the WASLookupServiceBegin when used for searching for a Bluetooth Device. If you run the code and monitor the "Mem Usage" in Task Manager the value increases. Similarly if you monitors "Private Bytes" for the process the pegged value increases.
This code was compiled using VS 2008. Has anyone else come across this or could someone possibly advise where my code sample is incorrect.
WSAQUERYSET querySet;
memset(&querySet, 0, sizeof(querySet));
querySet.dwSize = sizeof(querySet);
querySet.dwNameSpace = NS_BTH;
HANDLE hLookup;
DWORD flags = LUP_CONTAINERS;
for (int loop =0; loop < 32766; loop++)
{
int result = WSALookupServiceBegin(&querySet, flags, &hLookup);
if (0 == result)
{
printf("WSALookupServiceBegin() - ok. Loop: %d\n", loop);
result = WSALookupServiceEnd(hLookup);
}
else
{
printf("WSALookupServiceBegin() - Error: %s. Loop: %d\n", GetLastErrorMessage(GetLastError()), loop);
}
}
这篇关于重复调用WSALookupServiceBegin时发生内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!