I have used pageheap for debugging heap corruptions in last four years. generally, I don't have any problems with it. But now I have faced with weird behavior. After enabling pageheap for my process in win7-sp1-x86 host using global flags with following flags: -Enable heap tail checking -Enable heap free checking -Enable Page Heap
I noticed crashes with out-of-memory exceptions. !address -summary command said that ~90% of virtual memory was consumed by PageHeap.
It is really strange for me, because, as I know, pageheap should not lead to such big amount of memory overhead.
Can please someone explain whats is the reason of such behavior?
When running an application with full page-heap enabled, 2 pages (4kb) are allocated for each 'malloc'. When the memory is freed, these pages (or may be only the first one) are still 'reserved' : they don't occupy any physical or page file memory, but the virtual address range is made unavailable and an access violation is raised when trying to access this memory. This allows to catch read-after-free kind of bugs. Thus, the virtual address space of the application keeps on increasing even if you properly call free for each malloc.