This command line tool sets page heap flags that help to find
heap-related bugs and corruption. It can also help detect leaks in
applications that are running on Windows 2000 Professional SP2
and Windows XP Professional systems.
PageHeap introduces a software validation layer (Page Heap
manager) between the application and the system that verifies all
dynamic memory operations (allocations, frees, and other heap
operations). When Page Heap manager is enabled, the application
being tested is then launched under a debugger. If a bug is
encountered, it will cause a debugger break.
Important
PageHeap does not find bugs. It enables a verification layer
that already exists in the ntdll.dll system libraries in
Windows 2000 Professional SP2 and Windows XP
Professional. PageHeap will not work on previous versions of
Microsoft Windows.
If the application being tested is not launched under a
debugger and a bug is encountered, it will just crash without any
feedback.
A common problem in application development is heap corruption.
This typically occurs when an application allocates a block of heap
memory of a given size and then writes to memory addresses beyond
the requested size of the heap block. Heap corruption can also
occur when an application writes to block of memory that has
already been freed.
Two concepts are central to understanding the commands related
to PageHeap and the way to use it:
Corruptions in heap blocks are discovered by either placing a
non-accessible page at the end of the allocation, or by checking
fill patterns when the block is freed.
There are two heaps (full-page heap and normal page
heap) for each heap created within a process that has page heap
enabled.
Full-page heap reveals corruptions in heap blocks by
placing a non-accessible page at the end of the allocation. The
advantage of this approach is that you achieve "sudden death,"
meaning that the process will access violate (AV) exactly at the
point of failure. This behavior makes failures easy to debug. The
disadvantage is that every allocation uses at least one page of
committed memory. For a memory-intensive process, system resources
can be quickly exhausted.
Normal page heap can be used in situations where memory
limitations render full-page heap unusable. It checks fill patterns
when a heap block is freed. The advantage of this method is that it
drastically reduces memory consumption. The disadvantage is that
corruptions will only be detected when the block is freed. This
makes failures harder to debug.