Re: Memory fragmentation?
Jean-Marc Desperrier <[email protected]> Fri, 16 Nov 2007 13:25:06 +0100
| Newsgroups | gmane.comp.mozilla.performance |
|---|---|
| Message-ID | <[email protected]> |
Jean-Marc Desperrier wrote: > As a result, when you call VirtualFree, you can decommit any amount of > memory you want inside the VirtualAlloc block, but you can free only the > whole block. When you decommit memory with VirtualFree, you must > remember the area to recommit it later by giving it's address to > VirtualAlloc (with the flag MEM_COMMIT). VirtualAlloc with the flag > MEM_RESERVE will never give you back the address of that memory. A little more : There's also the MEM_RESET flag which can be used to say to the OS the data in the page is not important, so don't store it to the paging file. It's not very clear what this does it, but my understanding is this has the gain of memory decommitting, without having to do an OS call before using the memory again. But the memory will very certainly still "appear" as owned by the proccess. Some testing would be needed also to check how decommited memory is reported WRT freed memory. I've found a codeproject sample that plays with all that to release thread stack memory: http://www.codeproject.com/cpp/StackShrink.asp?df=100&forumid=253775&exp=0&select=1376692 BTW : To determine the size of a page and the allocation granularity on the host computer, use the GetSystemInfo function. http://msdn2.microsoft.com/en-us/library/ms724381.aspx The code project sample shows how to do the call and get the info.