WlanFreeMemory Problem!
Hi,
I'm here stuck in a problem regarding WlanFreeMemory. I'm trying to refresh Available network infromation every 100 millisecond. For this I'm calling WlanGetAvailableNetworkList every 100 millisecond, and then freeing up the pointer using WlanFreeMemory as follows:
Code Snippet
DWORD dReturn;
PWLAN_INTERFACE_INFO_LIST m_pAvailableInterfaces = NULL;
HANDLE m_phClientHandle;
PWLAN_AVAILABLE_NETWORK_LIST m_pVList=NULL;
DWORD pdwNegotiatedVersion;
dReturn = WlanOpenHandle(1,NULL,&pdwNegotiatedVersion,&m_phClientHandle);
dReturn = WlanEnumInterfaces(m_phClientHandle, NULL, &m_pAvailableInterfaces);
while(true){
dReturn=WlanGetAvailableNetworkList(m_phClientHandle,
&m_pAvailableInterfaces->InterfaceInfo[0].InterfaceGuid,0,NULL,&m_pVList);
WlanFreeMemory(m_pVList);
Sleep(100);
}
WlanFreeMemory(m_pAvailableInterfaces);
WlanCloseHandle(m_phClientHandle,NULL);
But the application crashes after some time as it over utilizes memory Heap. The heap for the process keeps on growing. I can't understand why it is happening, when I'm using WlanFreeMemory() each time after WlanGetAvailableNetworkList(). I've used HeapFree, GlobalFree functions as well but nothing's working. Please help me out here, it is really urgent...
HI KC apologies this is not an answer..
can you please know how to get started on compiling the above using VS 2005 on Windows XP?
I cant locate Wlanapi.h or lib files ... the dll is located in SYSROOT folder.
thanks!!
This is a known issue in XP.
BTW, you don't need to refresh available network information every 100 ms. The network information is not updated until a scan completes. By default, a scan is performed every minute.
Regards,
Yi
Hi Yi,
Thanks for letting me know that, but even if I'll refresh after one second, the application is going to crash eventually due to memory leak. Is there any solution that will fix the memory leak for once and for all? Please let me know ASAP...
Regards,
Rahul Sharma
I certainly hope it help Rahu.
I've been working hard on a Vist VB Implementation. I don't know if I have memory leaks or not because I haven't achieved a level of stability where that's a concern. The code is very good and I'm sampling once every teo seconds for my testing and initiating a scan after my request and I do see a dynamic picture using
WlanGetAvailableNetworkList.
However, after about 30 calls to WlanGetAvailableNetworkList, suddenly the API returns an empty initptr. Freeing the handle and re-opening it does repair it. I do use a handle over and over again without freeing it and I'm wondering if I should be open a handle every time I want to make a request?
I'm also wondering if anyone else has seen this or similar behavior? In the infolist, I discard the very first block of data because the SSID name if formatted in unicode and none of the subsequent block use that formating and the data is repeated so it looks like the first block is a throw away block. I also see duplicates and I discard dups but I realize that's not a great idea because many people use default SSID and vendors such as linksys use thier brand name as an SSID. But there are no unique identifiers in these structure.