template<typename T = uint8_t>
class esp_h264::PSRAMAllocatorH264< T >
STL-compatible allocator that prefers PSRAM allocation with fallback.
PSRAMAllocatorH264 is a custom C++ allocator that attempts to allocate memory in external PSRAM (using heap_caps_aligned_calloc with MALLOC_CAP_SPIRAM) and falls back to regular heap allocation if PSRAM allocation fails.
This allocator is particularly useful for ESP32 platforms with external PSRAM where large buffers (like video frames) should be stored in PSRAM to preserve internal SRAM for other uses. For small, frequently-accessed buffers that need fast access, consider using RAMAllocatorH264 instead.
- Template Parameters
-
| T | The type of objects to allocate |
- Note
- On ESP-IDF platforms, uses heap_caps_aligned_calloc for PSRAM allocation
-
On Arduino platforms, the heap_caps functions are shimmed to standard malloc/free
-
Memory is zero-initialized (calloc behavior)
-
Provides proper alignment for the allocated type
Example usage:
std::vector<uint8_t, PSRAMAllocatorH264<uint8_t>> largeBuffer;
largeBuffer.resize(1024 * 1024);
videoFrame.resize(640 * 480 * 3);
Header-only C++ allocator that prefers PSRAM allocation on ESP32.
Header-only C++ allocator that uses internal RAM (DRAM) on ESP32.
std::vector< T, RAMAllocatorH264< T > > RAMVec
Convenience type alias for vectors using RAMAllocatorH264.
Definition: RAMAllocatorH264.h:150
std::vector< T, PSRAMAllocatorH264< T > > PSVec
Convenience type alias for vectors using PSRAMAllocatorH264.
Definition: PSRAMAllocatorH264.h:155