Windows API Reference

Win32 System Information API

GetNumaAvailableMemoryNode

Retrieves the available memory on a specified NUMA node.

Syntax


ULONGLONG GetNumaAvailableMemoryNode(
  UCHAR NodeNumber
);
            

Parameters

NodeNumber
The NUMA node number. This parameter can be a value from 0 to (maximum NUMA node number - 1).

Return Value

ULONGLONG

On success, the function returns the amount of available memory on the specified NUMA node, in bytes. On failure, it returns 0. To get extended error information, call GetLastError.

Remarks

This function is available starting with Windows 7 and Windows Server 2008 R2.

NUMA (Non-Uniform Memory Access) is a system memory architecture that allows a processor to access its local memory faster than non-local memory. This can significantly improve performance for memory-intensive applications.

Requirements

Header

winnt.h (include windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

Example

C++ Example


#include <windows.h>
#include <iostream>

int main() {
    // Assume you have a known NUMA node number, e.g., Node 0
    UCHAR node = 0;
    ULONGLONG availableMemory = GetNumaAvailableMemoryNode(node);

    if (availableMemory > 0) {
        std::cout << "Available memory on NUMA node " << (int)node << ": " << availableMemory << " bytes." << std::endl;
    } else {
        DWORD error = GetLastError();
        std::cerr << "Failed to get available memory for NUMA node " << (int)node << ". Error code: " << error << std::endl;
    }

    return 0;
}