From d0d9cc4254c5ee2e7a70b4962eda9c5b9d34b56f Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sat, 13 May 2017 01:28:00 -0700 Subject: [PATCH] UI: Add function to get current memory usage (win32) --- UI/platform-windows.cpp | 12 ++++++++++++ UI/platform.hpp | 1 + 2 files changed, 13 insertions(+) diff --git a/UI/platform-windows.cpp b/UI/platform-windows.cpp index b3ee38d59..6675aa664 100644 --- a/UI/platform-windows.cpp +++ b/UI/platform-windows.cpp @@ -30,6 +30,7 @@ using namespace std; #include #include #include +#include #include #include @@ -259,3 +260,14 @@ bool DisableAudioDucking(bool disable) result = sessionControl2->SetDuckingPreference(disable); return SUCCEEDED(result); } + +uint64_t CurrentMemoryUsage() +{ + PROCESS_MEMORY_COUNTERS pmc = {}; + pmc.cb = sizeof(pmc); + + if (!GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc))) + return 0; + + return (uint64_t)pmc.WorkingSetSize; +} diff --git a/UI/platform.hpp b/UI/platform.hpp index 73ea999af..50efef300 100644 --- a/UI/platform.hpp +++ b/UI/platform.hpp @@ -43,6 +43,7 @@ void SetAeroEnabled(bool enable); void SetProcessPriority(const char *priority); void SetWin32DropStyle(QWidget *window); bool DisableAudioDucking(bool disable); +uint64_t CurrentMemoryUsage(); #endif #ifdef __APPLE__