_get_heap_handle

傳回 C 執行階段系統所使用之堆積的控制代碼。

語法

intptr_t _get_heap_handle( void );

傳回值

將控制代碼傳回至 C 執行階段系統所使用的 Win32 堆積。

備註

如果您想要在 CRT 堆積上呼叫 HeapSetInformation 並啟用低片段堆積,請使用此函式。

根據預設,此函式的全域狀態會限定于應用程式。 若要變更此行為,請參閱 CRT 中的全域狀態。

需求

常式 必要的標頭
_get_heap_handle <malloc.h>

如需相容性詳細資訊,請參閱相容性

範例

// 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;
}

另請參閱

記憶體配置