Hi,
I'm programming on a Samsung i730 with evc4. I've been monitoring memory usage when calling GetAdaptersInfo and I've noticed that it will randomly bump up the memory anywhere between 0-8192 b reguardless of the results I get. I do not know how to recover this memory. Since my program will be calling this function often, it will slowly consume all the memory. Does anyone know why this might happen
Here is some code:
IP_ADAPTER_INFO* aInfo= 0;
ULONG size = 0;
DWORD result = GetAdaptersInfo(aInfo, &size);
...
delete [] aInfo;
after this, the memory use can go up by any of 0, 4096, or 8192 bytes (bits )
Any help is much appreciated. Thanks.
TomC

Memory problem using GetAdaptersInfo?
Grit
for( int i = 0; i < 20000; i++ )
{
ULONG ulOutBufLen;
DWORD dwRetVal;
IP_ADAPTER_INFO *pAdapterInfo;
ulOutBufLen = 0;
//Call GetAdaptersInfo to get the size of the buffer
GetAdaptersInfo( NULL, &ulOutBufLen) ;
//Now that we know the necessary buffer size, allocate the memory
pAdapterInfo = (IP_ADAPTER_INFO *) malloc( ulOutBufLen );
dwRetVal = GetAdaptersInfo( pAdapterInfo, &ulOutBufLen);
if (pAdapterInfo)
free(pAdapterInfo);
}
However I still get memory loss running this function. I also want to note that this only happens on the Samsung i730 (WinCE 4.2). When I try this exact code on a WM5 device I don't see the memory loss.
j_ames2006
It seems you allways delete the adapterInfo but it should only be deleted if it is realy used. If you call GetAdaptersInfo with size 0 it wil return how large the block of memory should be. This wil be stored inside sz.
Calling GetAdaptersInfo with a valid pointer to a memory block will allow you to delete the buffer. Here is how it should be used:
http://msdn.microsoft.com/library/default.asp url=/library/en-us/iphlp/iphlp/getadaptersinfo.asp
And here is the original Windows CE 5.0 example:
http://msdn.microsoft.com/library/default.asp url=/library/en-us/wcecomm5/html/wce51concompleteiphelperapplicationsourcecode.asp
Bosikov
Pls refer to following link for more appropriate forums for this topic
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=286724&SiteID=1
Srikanth Bogadapati
Tjaalie
for( int i=0; i < 5000; i++ )
{
IP_ADAPTER_INFO* aInfo = 0;
ULONG sz = 0;
DWORD res = GetAdaptersInfo(aInfo, &sz);
delete [] adapterInfo;
}
I used GlobalMemoryStatus(&memInfo) to see the current memory during the process and after many loops, I can see the memory getting bumped up a bit at a time ( 4096 bytes ). Also there is no telling how long it takes for memory to increase. It just does it after some random iteration.
Rajaraman_85
How do you allocate the memory for the ID_ADAPTER_INFO structure Can you share the complete code where you have "..." above in the code sample
-Devidas