main: Log host system memory parameters
Logs both physical memory and swapfile sizes, this is useful for support.
This commit is contained in:
parent
65010607b7
commit
9a36d8600c
|
@ -123,6 +123,8 @@ add_library(common STATIC
|
||||||
lz4_compression.cpp
|
lz4_compression.cpp
|
||||||
lz4_compression.h
|
lz4_compression.h
|
||||||
math_util.h
|
math_util.h
|
||||||
|
memory_detect.cpp
|
||||||
|
memory_detect.h
|
||||||
memory_hook.cpp
|
memory_hook.cpp
|
||||||
memory_hook.h
|
memory_hook.h
|
||||||
microprofile.cpp
|
microprofile.cpp
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
// 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
|
|
@ -0,0 +1,22 @@
|
||||||
|
// Copyright 2020 yuzu Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/common_types.h"
|
||||||
|
|
||||||
|
namespace Common {
|
||||||
|
|
||||||
|
struct MemoryInfo {
|
||||||
|
u64 TotalPhysicalMemory{};
|
||||||
|
u64 TotalSwapMemory{};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the memory info of the host system
|
||||||
|
* @return Reference to a MemoryInfo struct with the physical and swap memory sizes in bytes
|
||||||
|
*/
|
||||||
|
const MemoryInfo& GetMemInfo();
|
||||||
|
|
||||||
|
} // namespace Common
|
|
@ -65,6 +65,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
|
||||||
#include "common/logging/backend.h"
|
#include "common/logging/backend.h"
|
||||||
#include "common/logging/filter.h"
|
#include "common/logging/filter.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
#include "common/memory_detect.h"
|
||||||
#include "common/microprofile.h"
|
#include "common/microprofile.h"
|
||||||
#include "common/scm_rev.h"
|
#include "common/scm_rev.h"
|
||||||
#include "common/scope_exit.h"
|
#include "common/scope_exit.h"
|
||||||
|
@ -219,6 +220,10 @@ GMainWindow::GMainWindow()
|
||||||
LOG_INFO(Frontend, "Host CPU: {}", Common::GetCPUCaps().cpu_string);
|
LOG_INFO(Frontend, "Host CPU: {}", Common::GetCPUCaps().cpu_string);
|
||||||
#endif
|
#endif
|
||||||
LOG_INFO(Frontend, "Host OS: {}", QSysInfo::prettyProductName().toStdString());
|
LOG_INFO(Frontend, "Host OS: {}", QSysInfo::prettyProductName().toStdString());
|
||||||
|
LOG_INFO(Frontend, "Host RAM: {:.2f} GB",
|
||||||
|
Common::GetMemInfo().TotalPhysicalMemory / 1024.0f / 1024 / 1024);
|
||||||
|
LOG_INFO(Frontend, "Host Swapfile: {:.2f} GB",
|
||||||
|
Common::GetMemInfo().TotalSwapMemory / 1024.0f / 1024 / 1024);
|
||||||
UpdateWindowTitle();
|
UpdateWindowTitle();
|
||||||
|
|
||||||
show();
|
show();
|
||||||
|
|
Loading…
Reference in New Issue