The PageHeap utility can be enabled for applications so that all malloc, new, and heapAlloc allocations are monitored automatically for memory errors.
This file contains the PageHeap utility, plus a PageHeap1 sample that demonstrates how to use the utility to detect memory errors.
Get PageHeap and give it a go to see just how useful it can actually be for you!
The PageHeap utility was originally written by Jeff Brown and can be found at
It is designed to detect an infinite loop in the Windows memory heap, which could occur if you call alloca() or new on a small, fixed-size buffer that is insufficient to hold all the memory you need.
The PageHeap utility has two modes: audit mode and a crash mode.
When activated by calling PageHeap(mode), it will run as a background process (as a service) and continuously scan the heap for memory errors. It will tell you when you create an error and provide detailed information about the error, including the number of errors, the file name and line number, and the address of the error.
It does not detect dangling pointers, double-free, or other difficult-to-detect errors.
There are no significant performance penalties for using PageHeap in an auditing mode, and it provides good protection against crashing your application.
It is most effective on Windows 2000 or later, because it can find memory errors when most memory allocation routines are already in use. The disadvantage is that it may incorrectly report a memory error when none exists, so use it with caution.
If you have a memory leak that results in infinite looping, you should go to the application error log and check for occurrences of the error that was reported by PageHeap. That way, you can easily see if your application really does have a problem.
Since the PageHeap utility has built-in memory allocations, there is no need for you to call HeapAlloc(), HeapFree(), or any of the other heap allocation routines. It simply uses the Windows memory heap to allocate and free its own memory.
It can also detect heaps that are improperly configured, such as heaps where one heap is not initialized before the next.
A typical application configuration is:
Set initial heap size to 128 megabytes.
Call HeapFree(NULL, 0, HEAP_ZERO_MEMORY) to initialize the heap.
Call HeapSetInformation(NULL, HEAP_FLAG_MEMORY_REPORT, NULL, 0) to enable memory heap reporting.
Use PageHeap() and PageHeap() for a complete proof-of-concept example.
To use the PageHeap utility, you can call the PageHe
PageHeap is a utility that can be run at any time while an application is running.
The PageHeap utility will periodically scan the working set for all malloc, new, and heapAlloc allocations.
If any errors are found, it will produce a listing of the offending memory addresses, functions, and call stacks.
The information in the listing is a great aid for debugging memory errors.
Like many of the commands in this package, it has a configuration file that you can use to customize the behavior of the PageHeap utility.
Additionally, it has options for running PageHeap in full or partially concurrent mode.
Be sure to check the “-?” command-line switch to see all of the options that this command can accept.
PageHeap has a sophisticated configuration file that allows you to select what types of code to monitor, such as:
* all applications
* one or more applications
The PageHeap utility can also be configured to run in concurrency mode or be passive.
In concurrency mode, it uses threads to perform its monitoring.
If you don’t want to use a concurrency mode, you can turn it off and just have PageHeap scan the working set.
The options are:
* Concurrency: When set to this value, the PageHeap utility will run in concurrency mode.
* Passive: When set to this value, PageHeap will run in the “passive” mode and will scan the working set every specified time.
* Memory Scanner: This is the minimum memory scan interval that PageHeap will perform.
It can be set to a time-value that represents a number of minutes or to a percentage of your memory.
For example, the value “50” would run a scan every 50% of the maximum available memory.
The following is an example of the configuration file for the PageHeap utility.
You will notice that there are several different groups of options that are separated by commas.
The options are separated by tabs.
There is a pair of commas at the end of the configuration file for the memory scanner.
You can set the memory scanner for either of the following:
* Scan time, in minutes, or
* Scan amount, in percentage
You can see these configuration options in effect by just running PageHeap,
There are two parts to the PageHeap utility: PageHeap Management and PageHeap Monitoring.
PageHeap can be used to enable or disable heap-based memory allocations for an entire application, or you can run a test application that has its heap allocation disabled, and can be run as a test (or demo) application in order to detect memory errors.
This utility runs in the same operating system thread as the test application and allocates memory using the same function calls that your test application uses.
The allocation functions still allocate memory from the global heap and the test application never knows that the memory is actually being monitored by PageHeap.
PageHeap also provides the ability to manage the address space, by creating additional small heaps in memory. When enabled, these heaps are automatically enabled and disabled when your test application is running and when it is not.
PageHeap Monitoring includes two types of operations: Basic and Extended.
Basic operations are ones that only report on the basic memory errors that PageHeap is capable of detecting. These include Out of Memory, Array Overflow, and Stack Overflow errors.
Extended operations are ones that perform more complex error checking and report on many types of memory errors. This includes detecting duplicate memory, heap corruption, and Heap Pointers Filled.
It is important to remember that even Extended operations only report on certain types of memory errors. Out of Memory errors are reported even if PageHeap does not have enough memory to continue.
Also, if your test application is running in an environment with a Debugger, such as Visual Studio, then the Extended operations will not report memory errors.
There are four ways that PageHeap can be used: 1) automatically when a test application is running in an environment that uses a Debugger 2) automatically when a test application is not running 3) on demand (manually) 4) in a demo or test application.
Each of these methods will be covered in the next sections.
1) Automatic When a Test Application is Running in an Environment that Uses a Debugger:
This is the preferred way to use PageHeap because it can detect and report on memory errors in applications that are running in environments that use a debugger. It is also the fastest way to detect and report on memory errors.
When a test application is running in an environment that uses a debugger, the PageHeap utility adds the following debug-
PageHeap is a utility for PageHeap – a page heap analyzer, error detector, and memory debugger. This is a utility for Win32 programs.
What is the PageHeap Utility For?
PageHeap is designed to be a memory error detector and logger. It is a simple utility with minimal requirements. No additional libraries are required. When PageHeap is used, malloc, new, and heapAlloc operations are monitored for memory errors.
PageHeap consists of the following parts:
PageHeap1.c (a sample program that demonstrates PageHeap)
PageHeap.c (the utility’s actual code)
PageHeap.hlp (the help file that you can use to understand and use PageHeap)
Manifest.txt (a list of file permissions required)
MSDN (version 2.0 source code of PageHeap)
This version of PageHeap was created on 10/18/2003.
To use the utility, you simply run the PageHeap utility in the command window. PageHeap’s own window will open to display the current error messages. The messages will display until PageHeap is closed.
How Do I Use PageHeap?
PageHeap is a simple utility that requires little instruction to use. To use PageHeap, first make sure PageHeap.dll is in your system PATH, then run the PageHeap utility from a command prompt as follows:
The PageHeap window will open and display any current error messages. To exit the utility, press the close button or press Ctrl-C to close the PageHeap window.
When you run PageHeap, the utility will start monitoring PageHeap’s heap to see if any memory errors are detected. If PageHeap detects an error, it will display the current error message on the PageHeap window.
PageHeap includes two forms of error detection and logging. First, PageHeap checks for memory access errors. This is a proactive approach in that it alerts you to potential problems.
When PageHeap detects an error, it logs the error message to the file specified with the –log parameter. This is a passive approach in that it provides a history of memory errors so that you can fix them later.
How Do I Adjust PageHeap’s Settings?
PageHeap comes with three settings that control how it operates:
–log: controls which file to use for logging purposes. The default is to use the current Windows event log.
–detect: controls whether to detect memory errors, or not.
–errlen: controls the length of time, in seconds, that PageHeap will wait before displaying error messages. The default is 300 seconds.
If you use the –log parameter
Vista users must use a supported version of XP Mode
Linux users must use a supported version of Wine
64-bit Intel-based PC
1 GB of free RAM
1 GB of free hard disk space
1024 x 768 pixel screen resolution
Windows or macOS
Completeaza formularul si te vom contacta in cel mai scurt timp