Share via


HeapQueryInformation 함수(heapapi.h)

지정된 힙에 대한 정보를 검색합니다.

구문

BOOL HeapQueryInformation(
  [in, optional]  HANDLE                 HeapHandle,
  [in]            HEAP_INFORMATION_CLASS HeapInformationClass,
  [out]           PVOID                  HeapInformation,
  [in]            SIZE_T                 HeapInformationLength,
  [out, optional] PSIZE_T                ReturnLength
);

매개 변수

[in, optional] HeapHandle

정보를 검색할 힙에 대한 핸들입니다. 이 핸들은 HeapCreate 또는 GetProcessHeap 함수에서 반환됩니다.

[in] HeapInformationClass

검색할 정보의 클래스입니다. 이 매개 변수는 HEAP_INFORMATION_CLASS 열거형 형식의 다음 값일 수 있습니다.

의미
HeapCompatibilityInformation
0
사용하도록 설정된 힙 기능을 나타냅니다.

HeapInformation 매개 변수는 ULONG 변수에 대한 포인터입니다.

HeapInformation이 0이면 힙은 외견 목록을 지원하지 않는 표준 힙입니다.

HeapInformation이 1이면 힙은 보기 목록을 지원합니다. 자세한 내용은 설명 부분을 참조하세요.

HeapInformation이 2이면 힙에 대해 LFH(하위 조각화 힙)가 사용하도록 설정되었습니다. LFH를 사용하도록 설정하면 목록 보기가 비활성화됩니다.

[out] HeapInformation

힙 정보를 수신하는 버퍼에 대한 포인터입니다. 이 데이터의 형식은 HeapInformationClass 매개 변수의 값에 따라 달라집니다.

[in] HeapInformationLength

쿼리되는 힙 정보의 크기(바이트)입니다.

[out, optional] ReturnLength

HeapInformation 버퍼에 기록된 데이터의 길이를 수신하는 변수에 대한 포인터입니다. 버퍼가 너무 작으면 함수가 실패하고 ReturnLength 가 버퍼에 필요한 최소 크기를 지정합니다.

이 정보를 받지 않으려면 NULL을 지정합니다.

반환 값

함수가 성공하면 반환 값이 0이 아닙니다.

함수가 실패하면 반환 값은 0입니다. 확장 오류 정보를 가져오려면 GetLastError를 호출합니다.

설명

LFH 또는 손상 종료 기능을 사용하도록 설정하려면 HeapSetInformation 함수를 사용합니다.

Windows XP 및 Windows Server 2003: 외면 목록은 고정 크기 블록만 포함하는 빠른 메모리 할당 메커니즘입니다. 조회 목록은 기본적으로 해당 목록을 지원하는 힙에 대해 사용하도록 설정됩니다. Windows Vista부터 보기 목록은 사용되지 않으며 LFH는 기본적으로 사용하도록 설정됩니다.

시스템이 할당에 맞는 사용 가능한 메모리를 검색하지 않으므로 보기 목록은 크기가 다른 일반 풀 할당보다 빠릅니다. 또한 보기 목록에 대한 액세스는 일반적으로 뮤텍스 또는 스핀 잠금 대신 빠른 원자 프로세서 교환 지침을 사용하여 동기화됩니다. 보기 목록은 시스템 또는 드라이버에서 만들 수 있습니다. 페이징된 풀 또는 비페이지 풀에서 할당할 수 있습니다.

예제

다음 예제에서는 GetProcessHeap 을 사용하여 기본 프로세스 힙에 대한 핸들을 가져오고 HeapQueryInformation 을 사용하여 힙에 대한 정보를 검색합니다.

#include <windows.h>
#include <tchar.h>
#include <stdio.h>

#define HEAP_STANDARD 0
#define HEAP_LAL 1
#define HEAP_LFH 2

int __cdecl _tmain()
{
    BOOL bResult;
    HANDLE hHeap;
    ULONG HeapInformation;

    //
    // Get a handle to the default process heap.
    //
    hHeap = GetProcessHeap();
    if (hHeap == NULL) {
        _tprintf(TEXT("Failed to retrieve default process heap with LastError %d.\n"),
                 GetLastError());
        return 1;
    }

    //
    // Query heap features that are enabled.
    //
    bResult = HeapQueryInformation(hHeap,
                                   HeapCompatibilityInformation,
                                   &HeapInformation,
                                   sizeof(HeapInformation),
                                   NULL);
    if (bResult == FALSE) {
        _tprintf(TEXT("Failed to retrieve heap features with LastError %d.\n"),
                 GetLastError());
        return 1;
    }

    //
    // Print results of the query.
    //
    _tprintf(TEXT("HeapCompatibilityInformation is %d.\n"), HeapInformation);
    switch(HeapInformation)
    {
    case HEAP_STANDARD:
        _tprintf(TEXT("The default process heap is a standard heap.\n"));
        break;
    case HEAP_LAL:
        _tprintf(TEXT("The default process heap supports look-aside lists.\n"));
        break;
    case HEAP_LFH:
        _tprintf(TEXT("The default process heap has the low-fragmentation ") \
                 TEXT("heap enabled.\n"));
        break;
    default:
        _tprintf(TEXT("Unrecognized HeapInformation reported for the default ") \
                 TEXT("process heap.\n"));
        break;
     }

    return 0;
}

요구 사항

요구 사항
지원되는 최소 클라이언트 Windows XP [데스크톱 앱만 해당]
지원되는 최소 서버 Windows Server 2003 [데스크톱 앱만 해당]
대상 플랫폼 Windows
헤더 heapapi.h(Windows.h 포함)
라이브러리 Kernel32.lib
DLL Kernel32.dll

참고 항목

GetProcessHeap

힙 함수

HeapCreate

HeapSetInformation

메모리 관리 함수