Sunday, November 9, 2008

Heap Demo is a project designed to show the relationship between virtual and committedmemory during heap use. Using a contrived scenario, a stair-step growth of virtualmemory can be observed in perfmon.

Open a new cpp file in Visual Studio. copy and paste code from this post. compile the file it will create project for u. then u can proceed further

1. Start the HeapDemo application.2. Open perfmon.3. Add counters for Virtual Bytes and Private Bytes for the HeapDemo Process.4. Change the scale for each counter to 0.0000001 (lowest value).5. Press ENTER on the console for HeapDemo to start the allocations.6. Watch the perfmon window as memory is allocated.

Note the stair step behavior of virtual memory. Each time the private bytes nears the amountof virtual bytes reserved, the memory manager extends the heap by reserving more virtualmemory. Each time the heap is extended, it reserves twice as much as the previous reservation.

// Tthe entry point for the console application.//

#include #include

void Test();

int main(int argc, char* argv[]){ Test();

return 0;}

void Test(){ int nCount = 0; int nTotal = 0; char c;

// scanf in here only to hold process in initial loaded state to set up PerfMon. printf("Set up Process Object's Private and Virtual Bytes for Heapdemo.exe, then hit ENTER to start the test\n"); scanf(&c);