Results 1 to 3 of 3

Thread: Virtual Memory

  1. #1

    Thread Starter
    Hyperactive Member made_of_asp's Avatar
    Join Date
    Jul 2001
    Location
    123 Fake Street
    Posts
    394

    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.
    VS.NET 2003

    Need to email me?

  2. #2
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    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?

  3. #3

    Thread Starter
    Hyperactive Member made_of_asp's Avatar
    Join Date
    Jul 2001
    Location
    123 Fake Street
    Posts
    394
    Thanks that works

    I got rid of MEM_DOCOMMIT & MEM_RESERVE
    VS.NET 2003

    Need to email me?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width