diff --git a/Library/MeasureMemory.cpp b/Library/MeasureMemory.cpp index 98afa4d6..84483431 100644 --- a/Library/MeasureMemory.cpp +++ b/Library/MeasureMemory.cpp @@ -47,12 +47,17 @@ CMeasureMemory::~CMeasureMemory() */ void CMeasureMemory::UpdateValue() { - if (!m_Total) - { - MEMORYSTATUSEX stat; - stat.dwLength = sizeof(MEMORYSTATUSEX); - GlobalMemoryStatusEx(&stat); + MEMORYSTATUSEX stat; + stat.dwLength = sizeof(MEMORYSTATUSEX); + GlobalMemoryStatusEx(&stat); + m_MaxValue = (double)(__int64)(stat.ullTotalPageFile + stat.ullTotalPhys); + if (m_Total) + { + m_Value = m_MaxValue; + } + else + { m_Value = (double)(__int64)(stat.ullTotalPageFile + stat.ullTotalPhys - stat.ullAvailPageFile - stat.ullAvailPhys); } } @@ -68,8 +73,4 @@ void CMeasureMemory::ReadOptions(CConfigParser& parser, const WCHAR* section) m_MaxValue = oldMaxValue; m_Total = (1 == parser.ReadInt(section, L"Total", 0)); - if (m_Total) - { - m_Value = m_MaxValue; - } } diff --git a/Library/MeasureVirtualMemory.cpp b/Library/MeasureVirtualMemory.cpp index 324c74b7..433712bc 100644 --- a/Library/MeasureVirtualMemory.cpp +++ b/Library/MeasureVirtualMemory.cpp @@ -47,12 +47,17 @@ CMeasureVirtualMemory::~CMeasureVirtualMemory() */ void CMeasureVirtualMemory::UpdateValue() { - if (!m_Total) - { - MEMORYSTATUSEX stat; - stat.dwLength = sizeof(MEMORYSTATUSEX); - GlobalMemoryStatusEx(&stat); + MEMORYSTATUSEX stat; + stat.dwLength = sizeof(MEMORYSTATUSEX); + GlobalMemoryStatusEx(&stat); + m_MaxValue = (double)(__int64)stat.ullTotalPageFile; + if (m_Total) + { + m_Value = m_MaxValue; + } + else + { m_Value = (double)(__int64)(stat.ullTotalPageFile - stat.ullAvailPageFile); } } @@ -68,9 +73,5 @@ void CMeasureVirtualMemory::ReadOptions(CConfigParser& parser, const WCHAR* sect m_MaxValue = oldMaxValue; m_Total = (1 == parser.ReadInt(section, L"Total", 0)); - if (m_Total) - { - m_Value = m_MaxValue; - } }