-
Virtual Memory
Hi,
I am trying to allocate heaps of memory and keep on getting memory leaks. HeapAlloc() works, but VirtualAlloc() gives leaks:
Code:
LPSTR pRead = (LPSTR)VirtualAlloc(NULL, config.dwSendHeap+1, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
VirtualFree(pRead, config.dwSendHeap+1, MEM_DECOMMIT | MEM_RELEASE);
Anyone can help to trace the leak?
Thanks.
-
You're call VirtualFree wrong - with MEM_RELEASE flag the size has to be zero:
Code:
VirtualFree(pRead, 0L, MEM_DECOMMIT | MEM_RELEASE);
Why do you have four arguments? Typo?
-
Thanks that works
I got rid of MEM_DOCOMMIT & MEM_RESERVE