Enigma 3.2.2
A Simple, Reliable and Efficient Encryption Tool
Loading...
Searching...
No Matches
RAMInfo.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef ENIGMA_RAM_INFO_H
3#define ENIGMA_RAM_INFO_H
4
5#include <Core/Core.hpp>
6#include <Logger/Logger.hpp>
7
8#if defined(ENIGMA_PLATFORM_WINDOWS)
9//https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/ns-sysinfoapi-memorystatusex
10#include <Windows.h>
11#include <psapi.h>
12typedef MEMORYSTATUSEX memory_status_t;
13#elif defined(ENIGMA_PLATFORM_LINUX)
14//https://man7.org/linux/man-pages/man2/sysinfo.2.html
15#include <stdio.h> // fopen
16#include <sys/syscall.h>
17#include <sys/sysinfo.h>
18#include <unistd.h> // syscall
19typedef struct sysinfo memory_status_t;
20#elif defined(ENIGMA_PLATFORM_MACOS)
21//https://stackoverflow.com/questions/5012886/determining-the-available-amount-of-ram-on-an-ios-device
22#include <mach/mach.h> // mach_task_basic_info
23#include <mach/mach_host.h>
24#include <mach/vm_statistics.h>
25typedef struct vm_statistics_data_t memory_status_t;
26#else
27#error "Unsupported Platform"
28#endif
29
34class RAMInfo {
35 public:
36 RAMInfo() noexcept;
37 ~RAMInfo() noexcept = default;
38
41
42 public:
46 void Update();
47
51 std::size_t GetUsedRAM() const noexcept;
52
56 std::size_t GetProcessUsedRAM() const noexcept;
57
61 std::size_t GetFreeRAM() const noexcept;
62
66 std::size_t GetAvailableRAM() const noexcept;
67
71 float GetRAMUsage() noexcept;
72
76 float GetProcessRAMUsage() noexcept;
77
78
79 private:
80 memory_status_t m_memory_status{};
81};
82
83
85
86
87#endif // !ENIGMA_RAM_INFO_H
#define NS_ENIGMA_BEGIN
Enable/Disable Assertions.
Definition Macros.hpp:13
#define NS_ENIGMA_END
Definition Macros.hpp:14
#define ENIGMA_NON_MOVEABLE(Class)
Definition Macros.hpp:114
#define ENIGMA_NON_COPYABLE(Class)
Prevent class copying or moving.
Definition Macros.hpp:111
std::size_t GetAvailableRAM() const noexcept
void Update()
RAMInfo() noexcept
float GetRAMUsage() noexcept
float GetProcessRAMUsage() noexcept
std::size_t GetFreeRAM() const noexcept
std::size_t GetProcessUsedRAM() const noexcept
std::size_t GetUsedRAM() const noexcept