memory during heap use. Using a contrived scenario, a stair-step growth of virtual
memory 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 amount
of virtual bytes reserved, the memory manager extends the heap by reserving more virtual
memory. Each time the heap is extended, it reserves twice as much as the previous reservation.
// Tthe entry point for the console application.
int main(int argc, char* argv)
int nCount = 0;
int nTotal = 0;
// 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");
while(nTotal < 200000)
int (*i) = new int;
nTotal += 100;
printf("Allocated: %d KB\n", nTotal);
printf("Hit any key to end the test and release all memory\n");