_fheapwalk() Does Not Check the Near Heap

ID: Q38327

5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a | 1.00 1.50

MS-DOS                      | OS/2            | WINDOWS
kbprg

The information in this article applies to:

In Microsoft C versions 5.1 and above, the HeapWalk routines are provided as an aid in debugging heap-related problems in programs. In large-, huge-, and compact-memory models _heapwalk() will map onto the function _fheapwalk(). In small- and medium-memory models, it maps onto function _nheapwalk(). The _fheapwalk() function does not check or examine the near heap in the default data segment, while _nheapwalk() examines only the near heap.

Because _fheapwalk() does not check the near heap, you should not assume that the HeapWalk routine will always reflect information about all your pointers when you are using compact-, large- and huge-memory models. This is because in these models, calloc() and malloc() will draw upon the far heap until it is exhausted, then turn to the near heap. In this case, it is possible to have valid pointers but _fheapwalk() will not acknowledge them. Starting in C 6.0 calloc() and malloc() do not allocate from the near heap when the far heap is exhausted.

For this reason, you should not assume that _fheapwalk() will provide information about all your pointers, or you should use both _fheapwalk() and _nheapwalk() to check both the near heap and the far heap.

Additional reference words: kbinf 1.00 1.50 6.00 6.00a 6.00ax 7.00 KBCategory: kbprg KBSubcategory: CRTIss Keywords : kb16bitonly

Last Reviewed: July 18, 1997