From 938495ab81a4bc6e9a894151aa4a56dc98eb68bd Mon Sep 17 00:00:00 2001 From: Vladyslav Baranovskyi Date: Tue, 11 Jun 2024 18:44:51 +0300 Subject: [PATCH] Fixed issue where on windows GetAppRamMax() returned less values than GetAppRamAvailable() --- openVulkanoCpp/Host/Windows/SystemInfo.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/openVulkanoCpp/Host/Windows/SystemInfo.cpp b/openVulkanoCpp/Host/Windows/SystemInfo.cpp index 49a5c70..6457544 100644 --- a/openVulkanoCpp/Host/Windows/SystemInfo.cpp +++ b/openVulkanoCpp/Host/Windows/SystemInfo.cpp @@ -48,13 +48,25 @@ namespace OpenVulkano { switch(type) { - case APP_MEM_TYPE::VM_MAX: return counters.PeakWorkingSetSize; + case APP_MEM_TYPE::VM_MAX: return counters.PeakPagefileUsage; case APP_MEM_TYPE::USED: return counters.PrivateUsage; } } Logger::PERF->error("Failed to get process memory info"); return 0; } + + size_t GetCommitLimit() + { + MEMORYSTATUSEX status; + status.dwLength = sizeof(status); + if(GlobalMemoryStatusEx(&status)) + { + return status.ullTotalPageFile; + } + Logger::PERF->error("Failed to get system commit limit"); + return 0; + } } size_t SystemInfo::GetSystemRam() @@ -69,12 +81,12 @@ namespace OpenVulkano size_t SystemInfo::GetAppRamMax() { - return std::min(GetSystemRam(), GetAppVirtualMemoryMax()); + return std::min(GetSystemRam(), GetCommitLimit()); } size_t SystemInfo::GetAppRamAvailable() { - return std::min(GetSystemRamAvailable(), GetAppVirtualMemoryMax() - GetAppRamUsed()); + return std::min(GetSystemRamAvailable(), GetCommitLimit() - GetAppRamUsed()); } size_t SystemInfo::GetAppRamUsed()