summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Morph2020-05-17 14:45:12 -0400
committerGravatar Morph2020-05-17 14:45:12 -0400
commit9a36d8600c0b263b4b3861b64051a4f62b4251d2 (patch)
tree65714fc37ebf294332c533db8b2dcefb67ef2562 /src
parentMerge pull request #3665 from bunnei/device-save (diff)
downloadyuzu-9a36d8600c0b263b4b3861b64051a4f62b4251d2.tar.gz
yuzu-9a36d8600c0b263b4b3861b64051a4f62b4251d2.tar.xz
yuzu-9a36d8600c0b263b4b3861b64051a4f62b4251d2.zip
main: Log host system memory parameters
Logs both physical memory and swapfile sizes, this is useful for support.
Diffstat (limited to 'src')
-rw-r--r--src/common/CMakeLists.txt2
-rw-r--r--src/common/memory_detect.cpp57
-rw-r--r--src/common/memory_detect.h22
-rw-r--r--src/yuzu/main.cpp5
4 files changed, 86 insertions, 0 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index e6769a5f3..264dff546 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -123,6 +123,8 @@ add_library(common STATIC
123 lz4_compression.cpp 123 lz4_compression.cpp
124 lz4_compression.h 124 lz4_compression.h
125 math_util.h 125 math_util.h
126 memory_detect.cpp
127 memory_detect.h
126 memory_hook.cpp 128 memory_hook.cpp
127 memory_hook.h 129 memory_hook.h
128 microprofile.cpp 130 microprofile.cpp
diff --git a/src/common/memory_detect.cpp b/src/common/memory_detect.cpp
new file mode 100644
index 000000000..b59a45d55
--- /dev/null
+++ b/src/common/memory_detect.cpp
@@ -0,0 +1,57 @@
1// Copyright 2020 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#ifdef _WIN32
6// clang-format off
7#include <windows.h>
8#include <sysinfoapi.h>
9// clang-format on
10#else
11#include <sys/types.h>
12#ifdef __APPLE__
13#include <sys/sysctl.h>
14#else
15#include <sys/sysinfo.h>
16#endif
17#endif
18
19#include "common/memory_detect.h"
20
21namespace Common {
22
23// Detects the RAM and Swapfile sizes
24static MemoryInfo Detect() {
25 MemoryInfo mem_info{};
26
27#ifdef _WIN32
28 MEMORYSTATUSEX memorystatus;
29 memorystatus.dwLength = sizeof(memorystatus);
30 GlobalMemoryStatusEx(&memorystatus);
31 mem_info.TotalPhysicalMemory = memorystatus.ullTotalPhys;
32 mem_info.TotalSwapMemory = memorystatus.ullTotalPageFile - mem_info.TotalPhysicalMemory;
33#elif defined(__APPLE__)
34 u64 ramsize;
35 struct xsw_usage vmusage;
36 // hw and vm are defined in sysctl.h
37 // https://github.com/apple/darwin-xnu/blob/master/bsd/sys/sysctl.h#L471
38 sysctlbyname(hw.memsize, &ramsize, sizeof(ramsize), NULL, 0);
39 sysctlbyname(vm.swapusage, &vmusage, sizeof(vmusage), NULL, 0);
40 mem_info.TotalPhysicalMemory = ramsize;
41 mem_info.TotalSwapMemory = vmusage.xsu_total;
42#else
43 struct sysinfo meminfo;
44 sysinfo(&meminfo);
45 mem_info.TotalPhysicalMemory = meminfo.totalram;
46 mem_info.TotalSwapMemory = meminfo.totalswap;
47#endif
48
49 return mem_info;
50}
51
52const MemoryInfo& GetMemInfo() {
53 static MemoryInfo mem_info = Detect();
54 return mem_info;
55}
56
57} // namespace Common \ No newline at end of file
diff --git a/src/common/memory_detect.h b/src/common/memory_detect.h
new file mode 100644
index 000000000..a73c0f3f4
--- /dev/null
+++ b/src/common/memory_detect.h
@@ -0,0 +1,22 @@
1// Copyright 2020 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "common/common_types.h"
8
9namespace Common {
10
11struct MemoryInfo {
12 u64 TotalPhysicalMemory{};
13 u64 TotalSwapMemory{};
14};
15
16/**
17 * Gets the memory info of the host system
18 * @return Reference to a MemoryInfo struct with the physical and swap memory sizes in bytes
19 */
20const MemoryInfo& GetMemInfo();
21
22} // namespace Common \ No newline at end of file
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 0b291c7d0..f690a1508 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -65,6 +65,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
65#include "common/logging/backend.h" 65#include "common/logging/backend.h"
66#include "common/logging/filter.h" 66#include "common/logging/filter.h"
67#include "common/logging/log.h" 67#include "common/logging/log.h"
68#include "common/memory_detect.h"
68#include "common/microprofile.h" 69#include "common/microprofile.h"
69#include "common/scm_rev.h" 70#include "common/scm_rev.h"
70#include "common/scope_exit.h" 71#include "common/scope_exit.h"
@@ -219,6 +220,10 @@ GMainWindow::GMainWindow()
219 LOG_INFO(Frontend, "Host CPU: {}", Common::GetCPUCaps().cpu_string); 220 LOG_INFO(Frontend, "Host CPU: {}", Common::GetCPUCaps().cpu_string);
220#endif 221#endif
221 LOG_INFO(Frontend, "Host OS: {}", QSysInfo::prettyProductName().toStdString()); 222 LOG_INFO(Frontend, "Host OS: {}", QSysInfo::prettyProductName().toStdString());
223 LOG_INFO(Frontend, "Host RAM: {:.2f} GB",
224 Common::GetMemInfo().TotalPhysicalMemory / 1024.0f / 1024 / 1024);
225 LOG_INFO(Frontend, "Host Swapfile: {:.2f} GB",
226 Common::GetMemInfo().TotalSwapMemory / 1024.0f / 1024 / 1024);
222 UpdateWindowTitle(); 227 UpdateWindowTitle();
223 228
224 show(); 229 show();