idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
memory.hpp File Reference

IDFXX memory utilities. More...

#include <idfxx/error.hpp>
#include <idfxx/flags.hpp>
#include <cstddef>
#include <cstdint>
#include <esp_heap_caps.h>
#include <limits>
#include <type_traits>

Go to the source code of this file.

Classes

struct  idfxx::heap_info
 Heap region statistics. More...
 
struct  idfxx::caps_allocator< T, Caps, Alignment >
 STL-compatible allocator for capability-based memory regions. More...
 
struct  idfxx::caps_allocator< T, Caps, Alignment >::rebind< U >
 Rebind the allocator to a different type. More...
 
struct  idfxx::heap_region
 Information about a heap region, passed to heap walk callbacks. More...
 
struct  idfxx::heap_block
 Information about a single heap block, passed to heap walk callbacks. More...
 

Namespaces

namespace  idfxx
 

Typedefs

template<typename T >
using idfxx::dram_allocator = caps_allocator< T, memory_caps::dram >
 STL-compatible allocator for internal DRAM.
 
template<typename T >
using idfxx::spiram_allocator = caps_allocator< T, memory_caps::spiram >
 STL-compatible allocator for external PSRAM (SPI RAM).
 
template<typename T >
using idfxx::dma_allocator = caps_allocator< T, memory_caps::dma >
 STL-compatible allocator for DMA-capable memory.
 
template<typename T , size_t Alignment>
using idfxx::aligned_dram_allocator = caps_allocator< T, memory_caps::dram, Alignment >
 STL-compatible aligned allocator for internal DRAM.
 
template<typename T , size_t Alignment>
using idfxx::aligned_spiram_allocator = caps_allocator< T, memory_caps::spiram, Alignment >
 STL-compatible aligned allocator for external PSRAM (SPI RAM).
 
template<typename T , size_t Alignment>
using idfxx::aligned_dma_allocator = caps_allocator< T, memory_caps::dma, Alignment >
 STL-compatible aligned allocator for DMA-capable memory.
 

Enumerations

enum class  idfxx::memory_caps : uint32_t {
  idfxx::memory_caps::exec = MALLOC_CAP_EXEC ,
  idfxx::memory_caps::access_32bit = MALLOC_CAP_32BIT ,
  idfxx::memory_caps::access_8bit = MALLOC_CAP_8BIT ,
  idfxx::memory_caps::dma = MALLOC_CAP_DMA ,
  idfxx::memory_caps::spiram = MALLOC_CAP_SPIRAM ,
  idfxx::memory_caps::internal = MALLOC_CAP_INTERNAL ,
  idfxx::memory_caps::default_heap = MALLOC_CAP_DEFAULT ,
  idfxx::memory_caps::iram = MALLOC_CAP_IRAM_8BIT ,
  idfxx::memory_caps::retention = MALLOC_CAP_RETENTION ,
  idfxx::memory_caps::rtc = MALLOC_CAP_RTCRAM ,
  idfxx::memory_caps::dma_desc_ahb = MALLOC_CAP_DMA_DESC_AHB ,
  idfxx::memory_caps::dma_desc_axi = MALLOC_CAP_DMA_DESC_AXI ,
  idfxx::memory_caps::cache_aligned = MALLOC_CAP_CACHE_ALIGNED ,
  idfxx::memory_caps::dram = internal | access_8bit
}
 Memory capability flags for heap allocations. More...
 

Functions

size_t idfxx::heap_total_size (flags< memory_caps > caps) noexcept
 Returns the total size of heap regions matching the given capabilities.
 
size_t idfxx::heap_free_size (flags< memory_caps > caps) noexcept
 Returns the current free size of heap regions matching the given capabilities.
 
size_t idfxx::heap_largest_free_block (flags< memory_caps > caps) noexcept
 Returns the largest free block in heap regions matching the given capabilities.
 
size_t idfxx::heap_minimum_free_size (flags< memory_caps > caps) noexcept
 Returns the minimum free size since boot for heap regions matching the given capabilities.
 
heap_info idfxx::get_heap_info (flags< memory_caps > caps) noexcept
 Returns detailed heap statistics for regions matching the given capabilities.
 
voididfxx::heap_malloc (size_t size, flags< memory_caps > caps) noexcept
 Allocates memory from heap regions matching the given capabilities.
 
voididfxx::heap_calloc (size_t n, size_t size, flags< memory_caps > caps) noexcept
 Allocates zero-initialized memory from heap regions matching the given capabilities.
 
voididfxx::heap_realloc (void *ptr, size_t size, flags< memory_caps > caps) noexcept
 Reallocates memory from heap regions matching the given capabilities.
 
void idfxx::heap_free (void *ptr) noexcept
 Frees memory previously allocated by heap allocation functions.
 
voididfxx::heap_aligned_alloc (size_t alignment, size_t size, flags< memory_caps > caps) noexcept
 Allocates aligned memory from heap regions matching the given capabilities.
 
voididfxx::heap_aligned_calloc (size_t alignment, size_t n, size_t size, flags< memory_caps > caps) noexcept
 Allocates aligned, zero-initialized memory from heap regions matching the given capabilities.
 
template<typename T , typename U , flags< memory_caps > Caps, size_t Alignment>
constexpr bool idfxx::operator== (const caps_allocator< T, Caps, Alignment > &, const caps_allocator< U, Caps, Alignment > &) noexcept
 Equality comparison for caps_allocator.
 
template<typename F >
void idfxx::heap_walk (flags< memory_caps > caps, F &&walker)
 Walk all heap blocks in regions matching the given capabilities.
 
template<typename F >
void idfxx::heap_walk_all (F &&walker)
 Walk all heap blocks across all heaps.
 
bool idfxx::heap_check_integrity (flags< memory_caps > caps, bool print_errors=false) noexcept
 Check integrity of all heaps with the given capabilities.
 
bool idfxx::heap_check_integrity_all (bool print_errors=false) noexcept
 Check integrity of all heaps.
 
void idfxx::heap_dump (flags< memory_caps > caps) noexcept
 Dump the structure of all heaps with matching capabilities.
 
void idfxx::heap_dump_all () noexcept
 Dump the structure of all heaps.
 

Variables

template<>
constexpr bool idfxx::enable_flags_operators< memory_caps > = true
 

Detailed Description

IDFXX memory utilities.

Definition in file memory.hpp.