SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
stk::memory::MemoryAllocator::Stats Class Reference

Snapshot of the memory allocator's statistics. More...

#include <stk_memory_allocator.h>

Public Member Functions

 Stats (size_t _capacity=CAPACITY_DEFAULT)
size_t GetCapacity () const
 Get total capacity of the memory pool.
size_t GetAvailable () const
 Get number of bytes currently available for allocation.
void RecordAllocate (size_t size)
 Record sucessful allocation.
void RecordFree (size_t size)
 Record sucessful deallocation.

Public Attributes

const size_t capacity
 Total capacity of the memory pool in bytes.
volatile size_t allocated
 Number of bytes currently allocated (dynamic value).
volatile size_t allocate_count
 Number of succesful allocations with Allocate().
volatile size_t free_count
 Number of succesful frees with Free().
volatile size_t min_ever_free
 Minimum free bytes recorded since system start (watermark).

Detailed Description

Snapshot of the memory allocator's statistics.

Definition at line 65 of file stk_memory_allocator.h.

Constructor & Destructor Documentation

◆ Stats()

stk::memory::MemoryAllocator::Stats::Stats ( size_t _capacity = CAPACITY_DEFAULT)
inline

Definition at line 67 of file stk_memory_allocator.h.

68 : capacity(_capacity), allocated(0U), allocate_count(0U), free_count(0U),
69 min_ever_free(_capacity)
70 {}
volatile size_t allocated
Number of bytes currently allocated (dynamic value).
volatile size_t allocate_count
Number of succesful allocations with Allocate().
const size_t capacity
Total capacity of the memory pool in bytes.
volatile size_t free_count
Number of succesful frees with Free().
volatile size_t min_ever_free
Minimum free bytes recorded since system start (watermark).

References allocate_count, allocated, capacity, stk::memory::MemoryAllocator::CAPACITY_DEFAULT, free_count, and min_ever_free.

Member Function Documentation

◆ GetAvailable()

size_t stk::memory::MemoryAllocator::Stats::GetAvailable ( ) const
inline

Get number of bytes currently available for allocation.

Returns
Available bytes.

Definition at line 86 of file stk_memory_allocator.h.

86{ return ((allocated < capacity) ? (capacity - allocated) : 0U); }

References allocated, and capacity.

Referenced by RecordAllocate(), and vPortGetHeapStats().

Here is the caller graph for this function:

◆ GetCapacity()

size_t stk::memory::MemoryAllocator::Stats::GetCapacity ( ) const
inline

Get total capacity of the memory pool.

Returns
Capacity in bytes.

Definition at line 81 of file stk_memory_allocator.h.

81{ return capacity; }

References capacity.

◆ RecordAllocate()

void stk::memory::MemoryAllocator::Stats::RecordAllocate ( size_t size)
inline

Record sucessful allocation.

Parameters
[in]sizeSize of allocated memory chunk.

Definition at line 91 of file stk_memory_allocator.h.

92 {
93 allocated += size;
96 }
static constexpr T Min(T a, T b) noexcept
Compile-time minimum of two values.
Definition stk_defs.h:753
size_t GetAvailable() const
Get number of bytes currently available for allocation.

References allocate_count, allocated, GetAvailable(), stk::Min(), and min_ever_free.

Here is the call graph for this function:

◆ RecordFree()

void stk::memory::MemoryAllocator::Stats::RecordFree ( size_t size)
inline

Record sucessful deallocation.

Parameters
[in]sizeSize of freed memory chunk.

Definition at line 101 of file stk_memory_allocator.h.

102 {
103 STK_ASSERT(allocated >= size);
104
105 allocated -= size;
106 ++free_count;
107 }
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
Definition stk_defs.h:516

References allocated, free_count, and STK_ASSERT.

Member Data Documentation

◆ allocate_count

volatile size_t stk::memory::MemoryAllocator::Stats::allocate_count

Number of succesful allocations with Allocate().

Definition at line 74 of file stk_memory_allocator.h.

Referenced by RecordAllocate(), Stats(), and vPortGetHeapStats().

◆ allocated

volatile size_t stk::memory::MemoryAllocator::Stats::allocated

Number of bytes currently allocated (dynamic value).

Definition at line 73 of file stk_memory_allocator.h.

Referenced by GetAvailable(), RecordAllocate(), RecordFree(), and Stats().

◆ capacity

const size_t stk::memory::MemoryAllocator::Stats::capacity

Total capacity of the memory pool in bytes.

Definition at line 72 of file stk_memory_allocator.h.

Referenced by GetAvailable(), GetCapacity(), and Stats().

◆ free_count

volatile size_t stk::memory::MemoryAllocator::Stats::free_count

Number of succesful frees with Free().

Definition at line 75 of file stk_memory_allocator.h.

Referenced by RecordFree(), Stats(), and vPortGetHeapStats().

◆ min_ever_free

volatile size_t stk::memory::MemoryAllocator::Stats::min_ever_free

Minimum free bytes recorded since system start (watermark).

Definition at line 76 of file stk_memory_allocator.h.

Referenced by RecordAllocate(), Stats(), and vPortGetHeapStats().


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