The Chromium Projects

Except as otherwise noted, the content of this page is licensed under a Creative Commons Attribution 2.5 license, and examples are licensed under the BSD License.

The Chromium OS designs and code are preliminary. Expect them to evolve.
For Developers‎ > ‎

Page Heap for Chromium

Page Heap is a Windows mode to help identify memory errors.

Enabling Page Heap

Everyone in the team should run memory checking tools as much as possible. The easiest way to do so is turning on page heap using gflags, which is already in chrome source tree under path chrome\tools\memory\gflags.exe

gflags.exe /p /enable chrome.exe /full

If chrome gets too slow with full page heap turned on, you can enable it on a partial address space

gflags.exe /p /address start_address end_address /enable chrome.exe /full

See Background section for more information on page heap and gflags.

Disabling Page Heap

I suggest you leave the flag on all the time. If you'd like to disable page heap (because you're running a perf test), run:

gflags.exe /p /disable chrome.exe

Background

1. Page heap is Window build-in support for heap verification. There are two modes:

- Full-Page heap places a non-accessible page at the end of the allocation. Full-page heap has high memory requirements. Its advantage is that a process will access violate (AV) exactly at the point of illegal memory operation.

- Normal page heap checks fill patterns when the block gets freed. Normal page heap can be used for testing large-scale process without the high memory consumption overhead of full-page heap. However, normal page heap delays detection until the blocks are freed - thus failures are more difficult to debug.

See this example for the effect of normal page heap and full page heap.

When an application foo.exe is launched, Windows looks up in "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\foo.exe" for page heap and other settings of the executable and acts accordingly.

2. To turn on page heap for an executable, one just needs to modify the settings in registry. Gflags is a utility downloadable from Microsoft to edit settings under "Image File Execution Options".

3. The enable-page-heap.py script described above turns on full-page heap for chrome process. However, if the full-page heap is turned on for the entire process, chrome runs very slowly and becomes not usable. Thus it only enables page heap for memory allocation from some specified 500k address range. Based on my experiment 500k gives a good balance between speed and address space coverage. The address space of chrome.dll in build 95 is from 0x10000000 to 0x10716000 and that is fixed at least on xp. The script will calculate a different 500k address space for different team members. So with many people in the team participate, we can cover the entire 0x10000000 to 0x10716000 address space of chrome.dll.

4. If you'd like to turn on page heap for larger address space or for the whole process, feel free to do so:

gflags.exe /p /enable chrome.exe /full

You may want to use "--disable-hang-monitor" in this case.

5. You may want to use a heap allocator other than tcmalloc when using PageHeap.
By default, chrome.exe now uses tcmalloc to allocate pages.  Because of this, many of PageHeap's benefits don't work.  To switch Chrome to use the default allocator, you can set the environment variable CHROME_ALLOCATOR=winheap.