Select the product you need help with
How to use the PageHeap utility to detect memory errors in a Microsoft Visual C++ projectArticle ID: 264471 - View products that this article applies to. This article was previously published under Q264471 Note Microsoft Visual C++ 2005, Microsoft Visual C++ .NET 2003, and Microsoft Visual C++ .NET 2002 support both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model. The information in this article applies only to unmanaged Visual C++ code. On This PageSummary The PageHeap utility can be enabled for applications so
that all malloc, new, and heapAlloc allocations are monitored automatically for
memory errors. This article contains the PageHeap utility, plus a PageHeap1
sample that demonstrates how to use the utility to detect memory errors.
PageHeap1 is a Microsoft Visual C++ project with several types of memory errors. To enable PageHeap on this sample application, type in the following from the command line: pageheap /enable pgh.exe 0x01 Then, type in the following, and note the application name that
PageHeap monitors: pageheap For many applications, 0x01 is the only flag you need. You can
get more information on its usage by running PageHeap with the question mark
flag (/?) from the command line.
Windows XP comes with a tool called Application Verifier which ships with the Application Compatibility Toolkit. This tool
can be used instead of PageHeap. The Application Verifier can be installed from the Support folder on the Windows XP CD-ROM
and is called Act20.exe. More information PageHeap returns a pointer to allocated memory on 8 byte
boundaries. The end of the returned pointer is followed by 0 to 7 guard bytes
(depending on the size requested, 0 to 7 bytes are added to round up the
request size to be on an 8 byte boundry), followed by a memory page marked
PAGE_NOACCESS (see VirtualAlloc documentation for more information). For
example: If the end of the allocation is overwritten, the guard bytes change and PageHeap causes an Access Violation (AV) when the memory is freed. If the application reads or writes past the allocation (including the guard bytes), it incurs an instant AV. How to use PageHeap1 sample
Visual C++ .NETCollapse this image ![]()
(http://download.microsoft.com/download/VisualStudioNET/sample/1.13/WIN98MeXP/EN-US/Pageheap1vcnet.exe)
For more information about how to download Microsoft support files, click the following article number to view the article in the Microsoft Knowledge Base: 119591
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help prevent any unauthorized changes to the file.
(http://support.microsoft.com/kb/119591/
)
How to obtain Microsoft support files from online services
PropertiesArticle ID: 264471 - Last Review: September 20, 2012 - Revision: 7.0 Applies to
| Article Translations |



Back to the top








