Skip to content

A custom allocator for using std::vector with PSRAM on ESP32. This implementation enables efficient dynamic memory allocation in PSRAM, making it ideal for large data structures such as graphics buffers, sensor data, and AI models.

Notifications You must be signed in to change notification settings

aeljandro2/esp32-psram-stdvector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

ESP32 PSRAM std::vector Allocator

🚀 Overview

This repository provides a custom allocator to enable std::vector to use PSRAM (Pseudo Static RAM) on ESP32. By default, C++ STL containers allocate memory in DRAM, which is limited. With this allocator, large dynamic structures can efficiently reside in PSRAM.

🎯 Why Use PSRAM?

  • Ideal for large data structures exceeding internal RAM.
  • Avoids heap fragmentation by managing memory efficiently.
  • Supports large buffers for graphics, sensor data, AI models, and more.

⚠️ Limitations

  • Not all STL containers are well-suited for PSRAM.
  • Works best with contiguous memory allocations like std::vector.
  • Node-based structures (std::map, std::unordered_map) may not perform optimally due to PSRAM’s large allocation preference.

🔧 Setup & Usage

🛠️ Prerequisites

  • ESP32 with PSRAM support enabled in the board configuration.
  • Arduino framework (ESP-IDF users can adapt accordingly).

About

A custom allocator for using std::vector with PSRAM on ESP32. This implementation enables efficient dynamic memory allocation in PSRAM, making it ideal for large data structures such as graphics buffers, sensor data, and AI models.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages