A static class containing helper functions for interrogating the memory status.
More...
#include <Memory.h>
|
static std::array< float, 3 > | _levels = {80, 90, 95} |
|
static const int | _pageSize = getpagesize() |
|
static unsigned long long | _maxMemory = 3221225472 |
|
A static class containing helper functions for interrogating the memory status.
◆ UnitType
Conversion factors for common memory usage units.
◆ Status
Aliases for memory occupation levels.
Enumerator |
---|
NORMAL | |
WARNING | |
CRITICAL | |
EXHAUSTED | |
◆ GetLevels()
static const std::array<float, 3>& EA::Memory::GetLevels |
( |
| ) |
|
|
inlinestatic |
Set the memory levels.
- Returns
- the array of memory levels.
- See also
- SetLevels
◆ GetMaxMemory()
static unsigned long long EA::Memory::GetMaxMemory |
( |
| ) |
|
|
inlinestatic |
Get the maximum allocable memory.
- Returns
- the maximum memory in bytes.
◆ GetOccupation()
unsigned long long EA::Memory::GetOccupation |
( |
| ) |
|
|
static |
Returns the current memory occupation in bytes.
The returned occupation is the resident memory used by the program instance.
- Returns
- the current memory occupation in bytes.
◆ GetStatus()
Returns a status code for the current memory occupancy.
Returns a status code corresponding to the current memory occupancy. See SetLevels for how to set the memory occupancy levels.
- Returns
- The status code of the current memory occupancy.
◆ SetLevels()
void EA::Memory::SetLevels |
( |
const std::array< float, 3 > & |
levels | ) |
|
|
static |
Set the memory levels.
Sets the memory occupation levels as percentages of the maximum allocable memory. Each value will mark the limit of memory statuses, for example:
SetLevels({70, 80, 95})
will set the NORMAL level at 70% or less of allocated memory, the WARNING level between 70% and 80%, the CRITICAL level between 80% and 95% and the EXHAUSTED level above 95%.
Values must be in the (0,100) range and be in strictly increasing order, otherwise a #BadLevelsException is thrown.
Default levels are {80, 90, 95}.
- Parameters
-
levels | The levels corresponding to the transitions between memory statuses. |
- Exceptions
-
BadLevelsException | if levels are not between 0 and 100 or not in strictly increasing order. |
◆ SetMaxMemory()
static void EA::Memory::SetMaxMemory |
( |
unsigned long long |
maxMemory | ) |
|
|
inlinestatic |
Set the maximum allocable memory.
Default value is 3221225472 bytes (3 GB).
- Parameters
-
maxMemory | The maximum memory in bytes. |
◆ _levels
std::array< float, 3 > EA::Memory::_levels = {80, 90, 95} |
|
staticprivate |
◆ _maxMemory
unsigned long long EA::Memory::_maxMemory = 3221225472 |
|
staticprivate |
◆ _pageSize
const int EA::Memory::_pageSize = getpagesize() |
|
staticprivate |
◆ GB
constexpr UnitType EA::Memory::GB = 1024UL * 1024UL * 1024UL |
|
static |
◆ KB
constexpr UnitType EA::Memory::KB = 1024UL |
|
static |
◆ MB
constexpr UnitType EA::Memory::MB = 1024UL * 1024UL |
|
static |
The documentation for this class was generated from the following files:
- /builds/mori/EventAnalysis/include/utils/Memory.h
- /builds/mori/EventAnalysis/src/utils/Memory.cpp