Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
_get_heap_handle
div
eof
Collapse the table of content
Expand the table of content

_get_heap_handle

Returns the handle of the heap used by the C run-time system.

Important note Important

This API cannot be used in applications that execute in the Windows Runtime except in Debug builds. For more information, see CRT functions not supported with /ZW.

intptr_t _get_heap_handle( void );

Returns the handle to the Win32 heap used by the C run-time system.

Use this function if you want to call HeapSetInformation and enable the Low Fragmentation Heap on the CRT heap.

Routine

Required header

_get_heap_handle

<malloc.h>

For more compatibility information, see Compatibility in the Introduction.

// crt_get_heap_handle.cpp
// compile with: /MT
#include <windows.h>
#include <malloc.h>
#include <stdio.h>

int main(void)
{
    intptr_t hCrtHeap = _get_heap_handle();
    ULONG ulEnableLFH = 2;
    if (HeapSetInformation((PVOID)hCrtHeap,
                           HeapCompatibilityInformation,
                           &ulEnableLFH, sizeof(ulEnableLFH)))
        puts("Enabling Low Fragmentation Heap succeeded");
    else
        puts("Enabling Low Fragmentation Heap failed");
    return 0;
}
Show:
© 2015 Microsoft