_fheapwalk() Does Not Check the Near Heap

Last reviewed: July 17, 1997
Article 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:

  • The C Run-time (CRT), included with:

        - Microsoft C for MS-DOS, versions 5.1, 6.0, 6.0a, and 6.0ax
        - Microsoft C for OS/2, versions 5.1, 6.0, and 6.0a
        - Microsoft C/C++ version 7.0
        - Microsoft Visual C++ for Windows, versions 1.0 and 1.5
    

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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.