#pragma once #include #include "esp_heap_caps.h" // Allocator custom per PSRAM template struct PSRAMAllocator { using value_type = T; PSRAMAllocator() noexcept {} template PSRAMAllocator(const PSRAMAllocator&) noexcept {} T* allocate(std::size_t n) { void* ptr = heap_caps_malloc(n * sizeof(T), MALLOC_CAP_SPIRAM); if (!ptr) { throw std::bad_alloc(); } return static_cast(ptr); } void deallocate(T* p, std::size_t) noexcept { heap_caps_free(p); } };