-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathMemory.h
141 lines (121 loc) · 5.04 KB
/
Memory.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#pragma once
///
/// \author John Farrier
///
/// \copyright Copyright 2018-2023 John Farrier
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
#include <celero/Export.h>
#include <cstdint>
#include <string>
namespace celero
{
///
/// \struct RAMReport
///
/// Contans all Memory measurements (in bytes)
///
class CELERO_EXPORT RAMReport
{
public:
int64_t RamSystemTotal{0};
int64_t RamSystemAvailable{0};
int64_t RamSystemUsed{0};
int64_t RamSystemUsedByCurrentProcess{0};
int64_t RamPhysicalTotal{0};
int64_t RamPhysicalAvailable{0};
int64_t RamPhysicalUsed{0};
int64_t RamPhysicalUsedByCurrentProcess{0};
int64_t RamPhysicalUsedByCurrentProcessPeak{0};
int64_t RamVirtualTotal{0};
int64_t RamVirtualAvailable{0};
int64_t RamVirtualUsed{0};
int64_t RamVirtualUsedByCurrentProcess{0};
operator std::string();
celero::RAMReport operator-(const celero::RAMReport& x);
};
// ----------------------------------------------------------------
// Physical + Virtual Memory
CELERO_EXPORT int64_t GetRAMSystemTotal();
CELERO_EXPORT int64_t GetRAMSystemAvailable();
CELERO_EXPORT int64_t GetRAMSystemUsed();
///
/// The sum of the physical RAM used by the current process and the virtual RAM used by the current process.
///
CELERO_EXPORT int64_t GetRAMSystemUsedByCurrentProcess();
// ----------------------------------------------------------------
// Physical Memory
///
/// The total physical RAM, in bytes.
/// https://msdn.microsoft.com/en-us/library/windows/desktop/aa366770(v=vs.85).aspx
///
CELERO_EXPORT int64_t GetRAMPhysicalTotal();
///
/// The total physical RAM available to the current process, in bytes.
///
/// On Windows, this is defined as "This is the amount of physical memory that can be immediately reused without having to write its contents to
/// disk first. It is the sum of the size of the standby, free, and zero lists."
/// https://msdn.microsoft.com/en-us/library/windows/desktop/aa366770(v=vs.85).aspx
///
CELERO_EXPORT int64_t GetRAMPhysicalAvailable();
///
/// The total amount of physical RAM minus the amount of physical RAM which is available.
///
CELERO_EXPORT int64_t GetRAMPhysicalUsed();
///
/// On Windows, this is defined by the Working Set Size. The working set size is defined as "The working set of a process is the set of pages in
/// the virtual address space of the process that are currently resident in physical memory. The working set contains only pageable memory
/// allocations; nonpageable memory allocations such as Address Windowing Extensions (AWE) or large page allocations are not included in the
/// working set."
/// https://msdn.microsoft.com/en-us/library/windows/desktop/ms684877(v=vs.85).aspx
/// https://msdn.microsoft.com/en-us/library/windows/desktop/cc441804(v=vs.85).aspx
///
CELERO_EXPORT int64_t GetRAMPhysicalUsedByCurrentProcess();
///
///
///
CELERO_EXPORT int64_t GetRAMPhysicalUsedByCurrentProcessPeak();
// ----------------------------------------------------------------
// Virtual Memory
///
/// The total amount of Virtual RAM (page file size).
///
/// On Windows, this is defined by the amount of page file that the current process has access to. It is not the total available on the system.
/// From the Windows documentation: "The current committed memory limit for the system or the current process, whichever is smaller, in bytes. To
/// get the system-wide committed memory limit, call GetPerformanceInfo."
///
CELERO_EXPORT int64_t GetRAMVirtualTotal();
///
/// The amount of non-physical memory (page file) available.
///
/// On Windows, this is defined by the amount of page file that the current process has access to. It is not the total available on the system.
/// From the Windows documentation: "The maximum amount of memory the current process can commit, in bytes. This value is equal to or smaller than
/// the system-wide available commit value."
///
CELERO_EXPORT int64_t GetRAMVirtualAvailable();
///
/// The total virtual RAM minus the available virtual RAM.
///
CELERO_EXPORT int64_t GetRAMVirtualUsed();
///
/// On Windows, this is defined as the commit charge. "The Commit Charge value in bytes for this process. Commit Charge is the total amount of
/// memory that the memory manager has committed for a running process."
/// https://msdn.microsoft.com/en-us/library/windows/desktop/ms684877(v=vs.85).aspx
///
CELERO_EXPORT int64_t GetRAMVirtualUsedByCurrentProcess();
///
/// Returns a RAMReport class containing all RAM measurements.
///
CELERO_EXPORT celero::RAMReport GetRAMReport();
} // namespace celero