INF: _fheapwalk() Does Not Check the Near Heap

ID Number: Q38327

5.10 6.00 6.00a 6.00ax | 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

In Microsoft C versions 5.1, 6.0, 6.0a, and 6.0ax, 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: 5.10 6.00 6.00a 6.00ax