VirtualBox

Changeset 43547 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 5, 2012 10:26:16 AM (12 years ago)
Author:
vboxsync
Message:

Main/PerformanceWin: switch to the runtime function for determining total/free RAM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/win/PerformanceWin.cpp

    r35368 r43547  
    301301int CollectorWin::getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available)
    302302{
    303     MEMORYSTATUSEX mstat;
    304 
    305     mstat.dwLength = sizeof(mstat);
    306     if (GlobalMemoryStatusEx(&mstat))
    307     {
    308         *total = (ULONG)( mstat.ullTotalPhys / 1024 );
    309         *available = (ULONG)( mstat.ullAvailPhys / 1024 );
    310         *used = *total - *available;
    311     }
    312     else
    313         return RTErrConvertFromWin32(GetLastError());
    314 
    315     return VINF_SUCCESS;
     303    uint64_t cb;
     304    int rc = RTSystemQueryTotalRam(&cb);
     305    if (RT_SUCCESS(rc))
     306    {
     307        *total = (ULONG)(cb / 1024);
     308        rc = RTSystemQueryAvailableRam(&cb);
     309        if (RT_SUCCESS(rc))
     310        {
     311            *available = (ULONG)(cb / 1024);
     312            *used = *total - *available;
     313        }
     314    }
     315    return rc;
    316316}
    317317
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette