From 7e115dcb00c5cabef0bcb920c7a0415dc731ec84 Mon Sep 17 00:00:00 2001 From: John Peterson Date: Mon, 7 Sep 2009 12:40:43 +0000 Subject: GUI: Fixed some GUI related start/stop crashes git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4223 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/MemoryUtil.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'Source/Core/Common/Src/MemoryUtil.cpp') diff --git a/Source/Core/Common/Src/MemoryUtil.cpp b/Source/Core/Common/Src/MemoryUtil.cpp index acbdaabcbe..478b31248a 100644 --- a/Source/Core/Common/Src/MemoryUtil.cpp +++ b/Source/Core/Common/Src/MemoryUtil.cpp @@ -17,9 +17,11 @@ #include "Common.h" #include "MemoryUtil.h" +#include "StringUtil.h" #ifdef _WIN32 #include +#include #elif __GNUC__ #include #include @@ -132,3 +134,28 @@ void UnWriteProtectMemory(void* ptr, size_t size, bool allowExecute) mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_WRITE | PROT_EXEC) : PROT_WRITE | PROT_READ); #endif } + + +std::string MemUsage() +{ + #ifdef _WIN32 + DWORD processID = GetCurrentProcessId(); + HANDLE hProcess; + PROCESS_MEMORY_COUNTERS pmc; + std::string Ret; + + // Print information about the memory usage of the process. + + hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID); + if (NULL == hProcess) return "MemUsage Error"; + + if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc))) + Ret = StringFromFormat("%s K", ThS(pmc.WorkingSetSize / 1024, true, 7).c_str()); + + CloseHandle(hProcess); + return Ret; + + #else + return ""; + #endif +} \ No newline at end of file -- cgit v1.2.3