Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Use PSRAM for large application data that does not need to be accessed directly by DMA: decoded image pixels, frame buffers, audio staging, and other byte arrays. In ESP-IDF, enable external SPI RAM and allocate deliberately with heap_caps_malloc(size, MALLOC_CAP_SPIRAM). Keep DMA-facing buffers in internal DMA-capable RAM, and avoid accessing PSRAM while flash cache is disabled. The exact capacity and address limits depend on the ESP32 target and board, so verify both before designing around a particular buffer size.
What does ESP32 PSRAM do, and when should I use it?
PSRAM is external RAM that expands the memory available for application data. It is useful when a project needs more space for large buffers than the chip’s internal RAM can comfortably provide. Espressif describes classic ESP32 as having only a few hundred kilobytes of internal RAM; external PSRAM gives you room for large data structures without treating every byte as scarce internal memory.
As an Amazon Associate I earn from qualifying purchases.
That extra capacity is not a universal replacement for internal RAM. PSRAM has different access constraints, shares cache resources with flash, and is excluded from ESP-IDF’s DMA-capable memory allocation. A good design assigns memory according to how the data is used, not simply according to which heap has space.
Good candidates for PSRAM
- Decoded image pixels: A compressed image may be small on storage but much larger after decoding. The pixel array is often a natural PSRAM allocation if the image-processing path can read it there.
- Frame buffers: A display or camera application may need one or more large image-sized arrays. Check whether the peripheral or driver requires the frame buffer itself to be DMA-capable before placing it in PSRAM.
- Audio sample storage: Longer sample queues, decoded audio, and staging buffers can use PSRAM when they are not the buffers directly consumed or filled by DMA.
- Large byte-addressable application data: Use PSRAM for data whose size would otherwise crowd internal memory, while keeping latency-sensitive or hardware-constrained data internal when required.
Estimate buffer size before choosing hardware
Calculate the memory requirement from the data format rather than using the compressed file size. For an uncompressed image, multiply width by height by bytes per pixel. For example, an 800 × 480 RGB565 pixel array requires 800 × 480 × 2 = 768,000 bytes, before any additional row padding, metadata, or second frame buffer. RGB565 here means two bytes per pixel; a format with more bytes per pixel needs proportionally more memory.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
For audio sample storage, estimate sample rate × channel count × bytes per sample × duration in seconds. For example, 48,000 samples per second × two channels × two bytes per sample × 0.1 seconds is 19,200 bytes for 100 milliseconds of uncompressed 16-bit stereo samples. This estimates sample payload only, not DMA descriptors, alignment, queue bookkeeping, or other application memory.
How do I enable PSRAM and allocate a large buffer?
In ESP-IDF, include the esp_psram component and enable external SPI RAM in menuconfig. Then choose whether the application will request PSRAM explicitly or allow ordinary malloc() calls to use it according to the project’s configuration.
- Confirm the target and board. Check that the selected ESP-IDF target and the physical board support the installed PSRAM. Board name alone is not enough; revisions and memory configurations can differ.
- Enable external RAM in the project configuration. In ESP-IDF’s
menuconfig, configure external SPI RAM for the target. The available options and labels can vary between ESP-IDF versions and chips, so use the options for the project’s selected target rather than relying on a menu path from another target. - Include the relevant component and headers. Add
esp_psramas a project component dependency where required by the project setup, and include the heap-capabilities header for explicit capability-based allocation. - Allocate by capability when the buffer specifically belongs in PSRAM. Request
MALLOC_CAP_SPIRAMso the allocator is asked for external RAM rather than relying on ordinary heap placement. - Check the allocation result before using it. If the allocator returns
NULL, handle the failure instead of assuming the buffer exists. Free a successfully allocated buffer withfree()when it is no longer needed.
#include <stdlib.h>
#include "esp_heap_caps.h"
size_t bytes = /* calculate the buffer size */;
uint8_t *buffer = heap_caps_malloc(bytes, MALLOC_CAP_SPIRAM);
if (buffer == NULL) {
// Handle allocation failure; do not use buffer.
} else {
// Use the PSRAM buffer.
free(buffer);
}
The example deliberately leaves bytes to the application: an image’s pixel format, audio sample format, and number of frames determine the correct size. Allocate only after those choices are known, and include any extra space required by the data layout.
Explicit allocation or ordinary malloc?
Explicit capability allocation makes the placement requirement visible at the allocation site. It is useful when one large buffer must be in PSRAM and other allocations should remain governed by the normal heap policy. ESP-IDF can also be configured so ordinary malloc() uses PSRAM; that mode can control whether larger allocations prefer external RAM. This can simplify code, but it makes placement depend on configuration rather than the call itself.
Choose explicit allocation when the buffer has a known memory requirement, especially when internal RAM must be preserved for DMA or other constrained uses. Choose malloc integration only when the project’s heap policy is understood and tested across its allocations. In either mode, a successful allocation does not establish that a peripheral can DMA directly from the resulting address.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Can I put image buffers in PSRAM?
Yes. PSRAM is a practical place for large decoded image arrays and frame buffers when the software processing path can access external memory. The key distinction is between an application-visible image buffer and a buffer that a peripheral must access through DMA.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Decoded pixels and display pipelines
For image decoding, size the allocation from the decoded dimensions and pixel representation. A compressed JPEG or other encoded file’s byte count is not the required output-buffer size. If the application needs multiple images or frames resident at once, calculate each allocation and the total peak memory use rather than sizing only for one image.
If image data must be sent to a display using DMA, do not assume the PSRAM-resident pixel array is itself a valid DMA source. Keep the DMA transfer buffer in internal DMA-capable memory and copy or stream portions of the image into it as needed. The exact chunk size is a design choice; account for the additional internal memory and copy operation in the application.
Frame buffers and target-specific limits
Confirm both the board’s actual PSRAM capacity and the selected chip’s supported memory range. Espressif’s classic ESP32 documentation describes up to 4 MB of PSRAM virtual addresses, while newer targets may have different limits. A board with more physical PSRAM does not by itself establish that a particular target, configuration, or allocator path can address all of it.
Can I use PSRAM for audio buffers?
Yes, for audio sample storage and staging that the application reads or writes directly. For audio hardware paths that use DMA, allocate the DMA-facing buffers and descriptors in internal DMA-capable RAM, then move audio between those blocks and PSRAM.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteRank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Separate storage capacity from the real-time transfer path
A useful arrangement is to keep a larger queue or sample store in PSRAM and use one or more smaller internal buffers for the immediate peripheral transfer. The internal blocks satisfy the DMA memory requirement; the PSRAM store supplies data to or receives data from them. This separation allows a project to reserve scarce internal memory for the hardware-facing portion without placing the entire audio workload there.
Do not interpret the audio example as a guarantee of a particular throughput, latency, or playback quality. Espressif’s cited documentation does not provide a universal PSRAM benchmark for audio rates or buffer performance. The target, transfer pattern, buffer size, and application all affect the result, so validate the complete audio path on the actual hardware.
Can ESP32 DMA access PSRAM directly?
Do not place a buffer in PSRAM if it must be directly accessible to ESP-IDF DMA. The MALLOC_CAP_DMA capability excludes external PSRAM, so DMA-facing buffers need internal DMA-capable memory.
This is a capability rule in ESP-IDF, not just a performance recommendation. For SPI or I2S paths, identify which memory the peripheral reads or writes directly, including descriptors where applicable, and allocate those objects with the appropriate internal DMA-capable requirements. Put larger staging or application buffers in PSRAM only when software can copy or stream the data through the internal DMA blocks.
Recommended Free Tools
Why does a PSRAM allocation fail?
A failed allocation means the requested capability allocation could not be satisfied. Check configuration, hardware support, requested size, and address limits before changing the buffer strategy.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
- External RAM is not enabled for the selected target. Verify the project’s external SPI RAM configuration and that the selected ESP-IDF target supports the board’s memory.
- The board does not have the expected PSRAM configuration. Verify the exact board revision, installed PSRAM capacity, operating voltage, and flash pairing. A WROVER-class designation is a useful starting category, not a substitute for checking the actual module.
- The request is larger than the usable region or available capacity. Compare the requested allocation with the actual PSRAM capacity and the target’s documented addressable range. Account for other allocations and the size of each simultaneous image, frame, or audio buffer.
- The request uses the wrong capability.
MALLOC_CAP_SPIRAMrequests external memory;MALLOC_CAP_DMAcannot be satisfied from external PSRAM. A DMA-only request for a PSRAM buffer conflicts with the documented capability rule. - The design assumes the classic ESP32 allocator covers memory above 4 MiB. For classic ESP32, direct external-SPI-RAM allocation is limited to the region below 4 MiB. Espressif documents the himem API for memory above that range; do not treat that memory as an ordinary direct allocation.
As a practical diagnostic, test a smaller PSRAM allocation after confirming configuration and board support. If the smaller request succeeds but the intended one does not, revisit the total peak memory requirement, contiguity needs of the allocation, and classic ESP32’s direct-allocation boundary. Do not infer a universal PSRAM limit from one board or one ESP-IDF target.
What happens to PSRAM during flash writes or large transfers?
PSRAM cannot be accessed while flash cache is disabled, such as during flash writes or erases. Espressif warns that an attempt to access external RAM during that window can cause an illegal cache-access exception. Design flash-write and OTA flows so code does not read or write PSRAM during cache-disabled intervals.
Large sequential accesses also need care. Espressif notes that accesses above roughly 32 KB can exceed cache effectiveness, fall back toward external-RAM access speed, and evict cached flash so code may run more slowly afterward. Treat that figure as a documented cache behavior, not as a universal optimum chunk size or a throughput guarantee. Benchmark the application’s own access pattern if large copies or scans are performance-critical.
Plan flash operations around buffer lifetime
Before a flash erase, write, or update path, identify any task, callback, or code path that might touch a PSRAM buffer during the cache-disabled interval. Arrange for those accesses to stop or for the flash operation to run only when the PSRAM-dependent work is not active. Avoid assuming that a buffer remains safely readable just because it was allocated and used successfully earlier.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Which ESP32 board or PSRAM configuration should I choose?
An ESP32-WROVER-class development board is a practical starting point for a project that needs external PSRAM. Espressif also produces modules and system-in-package devices that integrate compatible PSRAM and flash, but the exact memory configuration remains specific to the part and board.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
| What to compare | What to verify | Why it matters |
|---|---|---|
| PSRAM capacity and target support | Board or module’s stated PSRAM size, exact ESP32 target, and target-specific ESP-IDF limits | Physical capacity and addressable capacity are not interchangeable. |
| PSRAM and flash compatibility | Operating voltage and flash pairing for the specific board revision | A generic board family name does not establish electrical compatibility. |
| Memory allocation strategy | Explicit MALLOC_CAP_SPIRAM requests or configured malloc integration |
Placement policy affects which allocations use external RAM and how internal memory is reserved. |
| DMA requirements | Whether display, camera, SPI, or I2S transfers need direct DMA access to a buffer | DMA-capable allocation excludes external PSRAM, so the design may need internal transfer blocks. |
| Flash-operation behavior | Whether the application can avoid PSRAM access while flash cache is disabled | Flash writes and erases can make external RAM inaccessible temporarily. |
| Large-transfer needs | Whether the application performs sequential accesses above roughly 32 KB | Large accesses can reduce cache effectiveness and affect both PSRAM access and cached flash performance. |
| Memory above 4 MiB | Whether the selected target and API support the intended region; classic ESP32 needs himem above its direct-allocation range | Ordinary allocation paths do not cover every region on every ESP32 family. |
Before buying an ESP32 board with PSRAM, confirm its revision, PSRAM capacity, voltage, flash pairing, and compatibility with the exact ESP-IDF target. These checks are more useful than selecting a board from a family name alone.
Frequently Asked Questions
Does a larger PSRAM chip guarantee I can allocate one equally large buffer?
No. The memory must also be addressable by the selected target and available to the chosen allocator path. On classic ESP32, memory above the documented direct-allocation region requires the himem API rather than an ordinary direct allocation.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallHow much PSRAM does an image need if I know its file size?
The encoded file size is not enough to determine decoded-buffer capacity. Use the image width, height, and decoded bytes per pixel, then allow for any additional frames, padding, or processing buffers the application keeps at the same time.
Can a flash erase make an already allocated PSRAM buffer unusable?
Temporarily, yes: allocation does not make PSRAM accessible during a cache-disabled flash erase or write. Ensure no code path accesses the external buffer during that operation.
Is there a universal ESP32 PSRAM speed or audio-throughput figure?
The cited Espressif documentation does not establish one universal latency, frame-rate, or audio-throughput number. Performance depends on the target and access pattern, so evaluate the complete workload on the intended board.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Free tools Windows power users keep installed
One-click scans. No signup required.

