src/gc/windows/gcenv.windows.cpp
void GCToOSInterface::GetMemoryStatus(uint32_t* memory_load, uint64_t* available_physical, uint64_t* available_page_file)
{
    uint64_t restricted_limit = GetRestrictedPhysicalMemoryLimit();
    if (restricted_limit != 0)
    {
        size_t workingSetSize;
        BOOL status = FALSE;
        if (!g_UseRestrictedVirtualMemory)
        {
            PROCESS_MEMORY_COUNTERS pmc;
            status = GCGetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc));
            workingSetSize = pmc.WorkingSetSize;
        }

        if(status)
        {
            if (memory_load)
                *memory_load = (uint32_t)((float)workingSetSize * 100.0 / (float)restricted_limit);
            if (available_physical)
            {
                if(workingSetSize > restricted_limit)
                    *available_physical = 0;
                else
                    *available_physical = restricted_limit - workingSetSize;
            }
            // Available page file doesn't mean much when physical memory is restricted since
            // we don't know how much of it is available to this process so we are not going to 
            // bother to make another OS call for it.
            if (available_page_file)
                *available_page_file = 0;

            return;
        }
    }

    MEMORYSTATUSEX ms;
    ::GetProcessMemoryLoad(&ms);
    
    if (g_UseRestrictedVirtualMemory)
    {
        _ASSERTE (ms.ullTotalVirtual == restricted_limit);
        if (memory_load != NULL)
            *memory_load = (uint32_t)((float)(ms.ullTotalVirtual - ms.ullAvailVirtual) * 100.0 / (float)ms.ullTotalVirtual);
        if (available_physical != NULL)
            *available_physical = ms.ullTotalVirtual;

        // Available page file isn't helpful when we are restricted by virtual memory
        // since the amount of memory we can reserve is less than the amount of
        // memory we can commit.
        if (available_page_file != NULL)
            *available_page_file = 0;
    }
    else
    {
        if (memory_load != NULL)
            *memory_load = ms.dwMemoryLoad;
        if (available_physical != NULL)
            *available_physical = ms.ullAvailPhys;
        if (available_page_file != NULL)
            *available_page_file = ms.ullAvailPageFile;
    }
}
// Get memory status
// Parameters:
//  memory_load - A number between 0 and 100 that specifies the approximate percentage of physical memory
//      that is in use (0 indicates no memory use and 100 indicates full memory use).
//  available_physical - The amount of physical memory currently available, in bytes.
//  available_page_file - The maximum amount of memory the current process can commit, in bytes.
Get memory status
Parameters:
memory_load - A number between 0 and 100 that specifies the approximate percentage of physical memory
that is in use (0 indicates no memory use and 100 indicates full memory use).
available_physical - The amount of physical memory currently available, in bytes.
available_page_file - The maximum amount of memory the current process can commit, in bytes.
Get memory status Parameters : memory_load - A number between 0 and 100 that specifies the approximate percentage of physical memory that is in use ( 0 indicates no memory use and 100 indicates full memory use ) . available_physical - The amount of physical memory currently available in bytes . available_page_file - The maximum amount of memory the current process can commit in bytes .
void GCToOSInterface::GetMemoryStatus(uint32_t* memory_load, uint64_t* available_physical, uint64_t* available_page_file)
{
    uint64_t restricted_limit = GetRestrictedPhysicalMemoryLimit();
    if (restricted_limit != 0)
    {
        size_t workingSetSize;
        BOOL status = FALSE;
        if (!g_UseRestrictedVirtualMemory)
        {
            PROCESS_MEMORY_COUNTERS pmc;
            status = GCGetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc));
            workingSetSize = pmc.WorkingSetSize;
        }
        if(status)
        {
            if (memory_load)
                *memory_load = (uint32_t)((float)workingSetSize * 100.0 / (float)restricted_limit);
            if (available_physical)
            {
                if(workingSetSize > restricted_limit)
                    *available_physical = 0;
                else
                    *available_physical = restricted_limit - workingSetSize;
            }
            if (available_page_file)
                *available_page_file = 0;
            return;
        }
    }
    MEMORYSTATUSEX ms;
    ::GetProcessMemoryLoad(&ms);
    if (g_UseRestrictedVirtualMemory)
    {
        _ASSERTE (ms.ullTotalVirtual == restricted_limit);
        if (memory_load != NULL)
            *memory_load = (uint32_t)((float)(ms.ullTotalVirtual - ms.ullAvailVirtual) * 100.0 / (float)ms.ullTotalVirtual);
        if (available_physical != NULL)
            *available_physical = ms.ullTotalVirtual;
        if (available_page_file != NULL)
            *available_page_file = 0;
    }
    else
    {
        if (memory_load != NULL)
            *memory_load = ms.dwMemoryLoad;
        if (available_physical != NULL)
            *available_physical = ms.ullAvailPhys;
        if (available_page_file != NULL)
            *available_page_file = ms.ullAvailPageFile;
    }
}
void GCToOSInterface :: GetMemoryStatus ( uint32_t * memory_load , uint64_t * available_physical , uint64_t * available_page_file ) { uint64_t restricted_limit = GetRestrictedPhysicalMemoryLimit ( ) ; if ( restricted_limit != 0 ) { size_t workingSetSize ; BOOL status = FALSE ; if ( ! g_UseRestrictedVirtualMemory ) { PROCESS_MEMORY_COUNTERS pmc ; status = GCGetProcessMemoryInfo ( GetCurrentProcess ( ) , & pmc , sizeof ( pmc ) ) ; workingSetSize = pmc . WorkingSetSize ; } if ( status ) { if ( memory_load ) * memory_load = ( uint32_t ) ( ( float ) workingSetSize * 100.0 / ( float ) restricted_limit ) ; if ( available_physical ) { if ( workingSetSize > restricted_limit ) * available_physical = 0 ; else * available_physical = restricted_limit - workingSetSize ; } if ( available_page_file ) * available_page_file = 0 ; return ; } } MEMORYSTATUSEX ms ; :: GetProcessMemoryLoad ( & ms ) ; if ( g_UseRestrictedVirtualMemory ) { _ASSERTE ( ms . ullTotalVirtual == restricted_limit ) ; if ( memory_load != NULL ) * memory_load = ( uint32_t ) ( ( float ) ( ms . ullTotalVirtual - ms . ullAvailVirtual ) * 100.0 / ( float ) ms . ullTotalVirtual ) ; if ( available_physical != NULL ) * available_physical = ms . ullTotalVirtual ; if ( available_page_file != NULL ) * available_page_file = 0 ; } else { if ( memory_load != NULL ) * memory_load = ms . dwMemoryLoad ; if ( available_physical != NULL ) * available_physical = ms . ullAvailPhys ; if ( available_page_file != NULL ) * available_page_file = ms . ullAvailPageFile ; } }
Get memory status
Parameters:
memory_load - A number between 0 and 100 that specifies the approximate percentage of physical memory
that is in use (0 indicates no memory use and 100 indicates full memory use).
Get memory status Parameters : memory_load - A number between 0 and 100 that specifies the approximate percentage of physical memory that is in use ( 0 indicates no memory use and 100 indicates full memory use ) .
// Available page file doesn't mean much when physical memory is restricted since // we don't know how much of it is available to this process so we are not going to  // bother to make another OS call for it. // Available page file isn't helpful when we are restricted by virtual memory // since the amount of memory we can reserve is less than the amount of // memory we can commit.