mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-30 04:50:05 +00:00
a67f205cfe
Logs both physical memory and swapfile sizes, this is useful for support.
57 lines
1.5 KiB
C++
57 lines
1.5 KiB
C++
// Copyright 2020 yuzu Emulator Project
|
|
// Licensed under GPLv2 or any later version
|
|
// Refer to the license.txt file included.
|
|
|
|
#ifdef _WIN32
|
|
// clang-format off
|
|
#include <windows.h>
|
|
#include <sysinfoapi.h>
|
|
// clang-format on
|
|
#else
|
|
#include <sys/types.h>
|
|
#ifdef __APPLE__
|
|
#include <sys/sysctl.h>
|
|
#else
|
|
#include <sys/sysinfo.h>
|
|
#endif
|
|
#endif
|
|
|
|
#include "common/memory_detect.h"
|
|
|
|
namespace Common {
|
|
|
|
// Detects the RAM and Swapfile sizes
|
|
static MemoryInfo Detect() {
|
|
MemoryInfo mem_info{};
|
|
|
|
#ifdef _WIN32
|
|
MEMORYSTATUSEX memorystatus;
|
|
memorystatus.dwLength = sizeof(memorystatus);
|
|
GlobalMemoryStatusEx(&memorystatus);
|
|
mem_info.TotalPhysicalMemory = memorystatus.ullTotalPhys;
|
|
mem_info.TotalSwapMemory = memorystatus.ullTotalPageFile - mem_info.TotalPhysicalMemory;
|
|
#elif defined(__APPLE__)
|
|
u64 ramsize;
|
|
struct xsw_usage vmusage;
|
|
// hw and vm are defined in sysctl.h
|
|
// https://github.com/apple/darwin-xnu/blob/master/bsd/sys/sysctl.h#L471
|
|
sysctlbyname(hw.memsize, &ramsize, sizeof(ramsize), NULL, 0);
|
|
sysctlbyname(vm.swapusage, &vmusage, sizeof(vmusage), NULL, 0);
|
|
mem_info.TotalPhysicalMemory = ramsize;
|
|
mem_info.TotalSwapMemory = vmusage.xsu_total;
|
|
#else
|
|
struct sysinfo meminfo;
|
|
sysinfo(&meminfo);
|
|
mem_info.TotalPhysicalMemory = meminfo.totalram;
|
|
mem_info.TotalSwapMemory = meminfo.totalswap;
|
|
#endif
|
|
|
|
return mem_info;
|
|
}
|
|
|
|
const MemoryInfo& GetMemInfo() {
|
|
static MemoryInfo mem_info = Detect();
|
|
return mem_info;
|
|
}
|
|
|
|
} // namespace Common
|