diff options
| author | John Peterson <jpeterson57@gmail.com> | 2009-09-07 12:40:43 +0000 |
|---|---|---|
| committer | John Peterson <jpeterson57@gmail.com> | 2009-09-07 12:40:43 +0000 |
| commit | 7e115dcb00c5cabef0bcb920c7a0415dc731ec84 (patch) | |
| tree | 665545a388585ed0cbe92b994892e544c6f87d34 /Source/Core/Common/Src/MemoryUtil.cpp | |
| parent | 49601e0af2104eb0daca32d54840bc60bfea377f (diff) | |
GUI: Fixed some GUI related start/stop crashes
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4223 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common/Src/MemoryUtil.cpp')
| -rw-r--r-- | Source/Core/Common/Src/MemoryUtil.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
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 <windows.h> +#include <psapi.h> #elif __GNUC__ #include <sys/mman.h> #include <errno.h> @@ -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 |
