FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
FEAT::MemoryUsage Class Reference

Memory usage info object. More...

#include <memory_usage.hpp>

Public Types

enum  memory_type : std::uint8_t {
  peak_physical = 0 , cur_physical = 1 , peak_virtual = 2 , cur_virtual = 3 ,
  cur_swap = 4 , size = 5
}
 

Public Member Functions

std::size_t get_current_physical () const
 Returns current (last stamp call) physical memory. More...
 
std::size_t get_current_swap () const
 Returns current (last stamp call) swap memory. More...
 
std::size_t get_current_virtual () const
 Returns current (last stamp call) virtual memory. More...
 
String get_formatted_memory_usage () const
 Retrieve formatted memory usage string. More...
 
String get_formatted_memory_usage (const Dist::Comm &comm, memory_type mem_type) const
 
std::size_t get_peak_physical () const
 Returns peak physical memory. More...
 
std::size_t get_peak_virtual () const
 Returns peak virtual memory. More...
 
void stamp ()
 update the memory usage statistics with current data More...
 

Static Public Member Functions

static const char * format (memory_type type)
 
static String format_peak_physical_usage (const Dist::Comm &comm)
 Returns the formatted peak physical memory usage over an entire communicator. More...
 

Private Attributes

std::array< std::size_t, memory_type::size > _memory
 

Detailed Description

Memory usage info object.

This class is used to store and report memory usage statistics.

Note
The values reported by the various getter methods are all related to the moment when the object was instantiated or the last time, the stamp method was called. The term 'current' in the variables names has historic reasons.
Platform dependend code branching:
linux, windows and bsd all have different memory statistic tools
Note
Backport from FEAT 1 feat1/feat/kernel/arch/sysextra.c 3ccb13f633 and http://stackoverflow.com/questions/1558402/memory-usage-of-current-process-in-c

Definition at line 43 of file memory_usage.hpp.

Member Enumeration Documentation

◆ memory_type

enum FEAT::MemoryUsage::memory_type : std::uint8_t

Definition at line 46 of file memory_usage.hpp.

Constructor & Destructor Documentation

◆ MemoryUsage()

FEAT::MemoryUsage::MemoryUsage ( )
inline

Definition at line 78 of file memory_usage.hpp.

Member Function Documentation

◆ format()

static const char * FEAT::MemoryUsage::format ( memory_type  type)
inlinestatic

Definition at line 56 of file memory_usage.hpp.

◆ format_peak_physical_usage()

static String FEAT::MemoryUsage::format_peak_physical_usage ( const Dist::Comm comm)
inlinestatic

Returns the formatted peak physical memory usage over an entire communicator.

This function formats the sum of the peak memory usage over all ranks in the communicator as well as the maximum and the minimum peak memory usage.

Definition at line 260 of file memory_usage.hpp.

References get_formatted_memory_usage().

◆ get_current_physical()

std::size_t FEAT::MemoryUsage::get_current_physical ( ) const
inline

Returns current (last stamp call) physical memory.

Definition at line 202 of file memory_usage.hpp.

◆ get_current_swap()

std::size_t FEAT::MemoryUsage::get_current_swap ( ) const
inline

Returns current (last stamp call) swap memory.

Definition at line 226 of file memory_usage.hpp.

◆ get_current_virtual()

std::size_t FEAT::MemoryUsage::get_current_virtual ( ) const
inline

Returns current (last stamp call) virtual memory.

Definition at line 214 of file memory_usage.hpp.

◆ get_formatted_memory_usage() [1/2]

String FEAT::MemoryUsage::get_formatted_memory_usage ( ) const
inline

Retrieve formatted memory usage string.

Definition at line 232 of file memory_usage.hpp.

References FEAT::stringify().

Referenced by format_peak_physical_usage(), and FEAT::Control::Statistics::report().

◆ get_formatted_memory_usage() [2/2]

String FEAT::MemoryUsage::get_formatted_memory_usage ( const Dist::Comm comm,
memory_type  mem_type 
) const
inline

Definition at line 244 of file memory_usage.hpp.

◆ get_peak_physical()

std::size_t FEAT::MemoryUsage::get_peak_physical ( ) const
inline

Returns peak physical memory.

Definition at line 208 of file memory_usage.hpp.

◆ get_peak_virtual()

std::size_t FEAT::MemoryUsage::get_peak_virtual ( ) const
inline

Returns peak virtual memory.

Definition at line 220 of file memory_usage.hpp.

◆ stamp()

void FEAT::MemoryUsage::stamp ( )
inline

update the memory usage statistics with current data

Definition at line 85 of file memory_usage.hpp.

References FEAT::Windows::query_memory_usage(), FEAT::String::split_by_whitespaces(), FEAT::String::starts_with(), XABORTM, and XASSERTM.

Member Data Documentation

◆ _memory

std::array<std::size_t, memory_type::size> FEAT::MemoryUsage::_memory
private

Definition at line 75 of file memory_usage.hpp.


The documentation for this class was generated from the following file: