Where did 512 KB go? The ESP32-S3 memory map
The ESP32-S3 has 512 KB of SRAM, but a fresh Arduino sketch sees about 350 KB of free heap, and the largest block it can allocate is about 300 KB. Here is where the rest goes, with addresses and numbers printed on a real board.
In short
- In
setup()of a small test sketch,ESP.getFreeHeap()returns 359,024 bytes andESP.getMaxAllocHeap()returns 303,092, out of 524,288 bytes of SRAM. - The 512 KB split, to the byte: 48 KB cache (16 KB instructions + 32 KB data), 60.5 KB code in IRAM, 21.2 KB global variables, 2.9 KB kept by the ROM drivers, 379.5 KB heap. Before
setup()the system has already taken 36.4 KB of that heap. - The heap is five separate regions, so the largest single allocation is smaller than the free total. Check
getMaxAllocHeap()before a bigmalloc. - With PSRAM enabled (it is disabled by default in Arduino IDE),
malloc(4096)stays in internal SRAM andmalloc(4097)goes to PSRAM.newbehaves the same. - Reading a new cache line costs 12 cycles from internal SRAM, 120 from PSRAM and 283 from flash, once the data no longer fits in the cache.
512 KB on paper, 350 KB in practice
The ESP32-S3 datasheet lists 512 KB of on-chip SRAM “for data and instructions”. Ask a fresh Arduino sketch how much of it is free, and the answer is noticeably smaller:
ESP.getFreeHeap() = 359024
ESP.getMaxAllocHeap() = 303092
That is 350.6 KB free, about 68% of the SRAM, and the biggest block a single malloc can return is 296 KB. Both numbers were printed in setup() on an ESP32-S3 with arduino-esp32 3.3.12 and default board settings.
The rest is not lost. Part of the SRAM works as a cache for flash and PSRAM, part holds code that must not live in flash, part holds global variables, and the system takes some of the heap before your code starts. The sections below account for every byte.
Throughout this page, 1 KB = 1024 bytes, as in Espressif's documentation.
The memory map
On the chip itself there are:
- ROM, 384 KB: “for booting and core functions”.
- Internal SRAM, 512 KB, built from three blocks: SRAM0 (32 KB), SRAM1 (416 KB) and SRAM2 (64 KB).
- RTC FAST and RTC SLOW memory, 8 KB each. Both can retain data in deep sleep: in that mode only the RTC controller, the ULP coprocessor and these two memories stay powered.
Flash and PSRAM are external. The CPU does not read them directly: the datasheet describes access “through high-speed caches”, and the MMU maps the external memory into the address space. Flash and PSRAM share one 32 MB virtual address window and the same cache.
| Memory | Size | How the CPU reaches it |
|---|---|---|
| ROM | 384 KB | on chip |
| Internal SRAM (SRAM0 + SRAM1 + SRAM2) | 32 + 416 + 64 KB | on chip |
| RTC FAST | 8 KB | on chip, kept in deep sleep |
| RTC SLOW | 8 KB | on chip, kept in deep sleep |
| Flash (16 MB on the test board) | external | through the cache and the MMU |
| PSRAM (8 MB OPI on the test board) | external | through the same cache and MMU |
Where the 512 KB go
Using linker symbols, the core's precompiled sdkconfig and the list of heap regions, the 524,288 bytes of SRAM can be accounted for exactly:
| Part | Bytes | Where the number comes from |
|---|---|---|
| Instruction cache (ICache) | 16,384 | CONFIG_ESP32S3_INSTRUCTION_CACHE_SIZE=0x4000; IRAM starts at 0x40374000 = 0x40370000 + 0x4000 |
| Data cache (DCache) | 32,768 | CONFIG_ESP32S3_DATA_CACHE_SIZE=0x8000; the heap in SRAM2 is only 0x3FCF0000, 32,768 bytes, the other half is the cache |
Code in IRAM (IRAM_ATTR, core, FreeRTOS, …) | 61,952 | _iram_start … _iram_end |
Global variables, .data + .bss | 21,688 | _data_start … heap start |
| ROM driver variables | 2,936 | ROM layout table read from the chip, see below |
| Heap in internal SRAM | 388,560 | sum of the heap regions from heap_caps_print_heap_info |
| Total | 524,288 | = 512 KB |
Cache: 48 KB
Part of SRAM0 can be allocated “to either CPU or ICACHE”, and part of SRAM2 “to either CPU/GDMA or DCACHE”. The arduino-esp32 build uses 16 KB for the instruction cache and 32 KB for the data cache. That memory is never visible to your sketch.
Code in IRAM: about 60 KB
By default code goes to flash. Code that has to run from RAM, such as interrupt handlers and timing-critical parts of the system, is placed into internal SRAM instead. In this build that is 61,952 bytes.
Global variables: about 21 KB
Initialized globals (.data) and zero-initialized globals (.bss) sit in SRAM right after the IRAM code. In this build .data is 14,630 bytes and .bss 7,056 bytes.
Heap: about 380 KB
Everything that is left becomes the heap: 388,560 bytes of internal SRAM. The memory the ROM used during boot is also returned to it; ESP-IDF's memory_layout.c marks that area as “ROM reserved area, recycled by heap allocator in app_main task”.
Arduino also adds the 8 KB RTC FAST memory to the heap (CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y): 8,152 bytes at 0x600FE000. That is why ESP.getHeapSize() reports 396,712 = 388,560 + 8,152.
The 2,936 bytes kept by the ROM
After adding up cache, IRAM, globals and heap, 2,936 bytes were still missing. They belong to code that is built into the chip's ROM.
The ROM contains a memory layout table (ets_rom_layout_p, structure ets_rom_layout_t from esp_rom/esp32s3/include/esp32s3/rom/rom_layout.h). At start-up ESP-IDF reserves everything from dram0_rtos_reserved_start to the end of SRAM1 (components/heap/port/memory_layout_utils.c). On the test chip that is 0x3FCEEE34 … 0x3FCF0000, 4,556 bytes. The table read from the chip shows what is inside: the .data and .bss of the ROM's own drivers.
| Addresses | Bytes | What |
|---|---|---|
0x3FCEEE34 … 0x3FCEF130 | 764 | USB driver in ROM |
0x3FCEF130 … 0x3FCEF174 | 68 | UART in ROM |
0x3FCEF174 … 0x3FCEF1A4 | 48 | Bluetooth in ROM, data + bss |
0x3FCEF1A4 … 0x3FCEF3D4 | 560 | Wi-Fi in ROM: coexist, net80211, pp |
0x3FCEF3D4 … 0x3FCEF66C | 664 | PHY (radio) in ROM |
0x3FCEF66C … 0x3FCEF820 | 436 | not described in the table |
0x3FCEF820 … 0x3FCEF958 | 312 | Wi-Fi interface tables in ROM |
0x3FCEF958 … 0x3FCEFFAC | 1,620 | not kept: this range is a heap region |
0x3FCEFFAC … 0x3FCF0000 | 84 | ROM global pointers (syscall_table_ptr at 0x3FCEFFD4, ets_ops_table_ptr at 0x3FCEFFFC and others, from esp32s3.rom.ld) |
764 + 68 + 48 + 560 + 664 + 436 + 312 + 84 = 2,936 bytes, exactly the amount that was missing.
The heap is five separate pieces
Two things make the usable heap smaller than 380 KB.
The system gets there first
By the time setup() runs, the system has already allocated 37,296 bytes (36.4 KB) of the heap in internal SRAM: task stacks, including the 8 KB stack of loopTask, Serial buffers and similar. The ESP-IDF heap documentation says the same in general terms: “some memory is allocated from the heap before the FreeRTOS scheduler is started”.
The arithmetic: 359,024 bytes are free, 7,760 of them in RTC FAST, so 351,264 are free in SRAM, out of 388,560.
The free memory is not contiguous
The heap is assembled from whatever was left between everything else, and “each contiguous region of memory contains its own memory heap”. On the test board there are five regions:
| Start | Length, B | Free in setup() | What it is |
|---|---|---|---|
0x3FC986B8 | 331,864 | 309,112 | main part of SRAM1, right after .bss |
0x3FCF0000 | 32,768 | 32,020 | SRAM2; the other half is the data cache |
0x3FCE9710 | 22,308 | 9,828 | memory the ROM used during boot |
0x600FE000 | 8,152 | 7,760 | RTC FAST |
0x3FCEF958 | 1,620 | 0 | inside the ROM-reserved range |
One malloc can only take memory from one region. The largest free block is in the main region: 303,092 bytes. So the largest single allocation is about 296 KB, not 350.
The heap documentation warns about exactly this: because of fragmentation, “it is probably not possible to allocate a single block of memory of this size”, and points to heap_caps_get_largest_free_block(). In Arduino that is what ESP.getMaxAllocHeap() returns.
In one test sketch, after a 256 KB malloc from internal memory, a further 128 KB and even a 64 KB malloc failed, although about 100 KB was free in total: the free space was split across regions. malloc returned NULL, and the following memcpy into NULL crashed with StoreProhibited.
if (ESP.getMaxAllocHeap() < size) { /* won't fit in one piece */ }
One memory, two addresses
SRAM1, the 416 KB block that holds most of the memory, is “accessed by CPU's DBUS, IBUS and GDMA at the same time”: it is wired both to the instruction bus and to the data bus, at different addresses. The same byte has two addresses.
On the test board, the IRAM code and the global variables meet in the middle:
IRAM code ends 0x40383200 (instruction bus)
.data starts 0x3FC93200 (data bus)
The last digits match. The difference, 0x6F0000, is exactly the offset between the two buses for SRAM1: 0x40378000 − 0x3FC88000 in memory.ld. It is the same spot in the same physical SRAM, seen through two buses. ESP-IDF's memory_layout.c relies on this: “the part used by code is reserved … directly shift IRAM address to get reserved DRAM address”.
The boundary moves with the amount of IRAM code. With PSRAM: OPI PSRAM the same sketch has 65,280 bytes of IRAM code, IRAM ends at 0x40383F00, and .data starts at 0x3FC93F00: the boundary moved along with it.
“Any internal SRAM which is not used for Instruction RAM will be made available as DRAM.” The reverse is also true: every function you mark with IRAM_ATTR takes RAM away from your data and your heap.
Where your sketch lives
The test sketch prints the address of typical objects and checks which region each one falls into. The short version:
void blink() {...} // 0x4201FB8C flash
void IRAM_ATTR onPulse() {...} // 0x40377B20 IRAM
const uint32_t table[256] = {...}; // 0x3C0391EC flash
"hello" // 0x3C030487 flash
uint32_t counter; // 0x3FC96B28 SRAM
void setup() { uint32_t x; ... } // 0x3FCEBD1C SRAM, loopTask stack
RTC_DATA_ATTR uint32_t bootCount; // 0x50000200 RTC
- Normal functions run from flash, through the cache. “If a function is not explicitly placed into IRAM … or RTC memory, it is placed into flash.”
IRAM_ATTRfunctions sit in internal SRAM, on the instruction bus. The ESP-IDF docs note that “placing a function into IRAM may reduce delays caused by a cache miss”.consttables and string literals stay in flash. “By default, constant data is placed by the linker into a region mapped to the MMU flash cache.”- Global variables go to internal SRAM, on the data bus: initialized ones into
.data, the rest into.bss. Astaticvariable inside a function lands in.datatoo. - Local variables of
setup()andloop()live on the stack of theloopTasktask, which Arduino creates withxTaskCreateUniversal(loopTask, "loopTask", getArduinoLoopTaskStackSize(), …); the stack size isCONFIG_ARDUINO_LOOP_STACK_SIZE=8192. The stack is allocated from the heap. RTC_DATA_ATTRputs a variable into RTC SLOW memory, where it survives deep sleep (see below).
One detail from the ROM layout table: the ROM runs on two 8 KB boot stacks, 0x3FCE9710 … 0x3FCEB710 (core 0) and 0x3FCEB710 … 0x3FCED710 (core 1). After start-up that memory becomes the heap region at 0x3FCE9710, and the loopTask stack was allocated there. The local variable x in setup(), at 0x3FCEBD1C, sits where the ROM kept the boot stack of the second core.
The full list, with PSRAM disabled (default) and enabled:
| Object | PSRAM off | PSRAM on (OPI) | Region |
|---|---|---|---|
| normal function | 0x4201FB8C | 0x4201FFAC | flash, through the cache |
IRAM_ATTR function | 0x40377B20 | 0x40377C58 | internal SRAM, instruction bus |
const uint32_t table[] | 0x3C0391EC | 0x3C03931C | flash, through the cache |
| string literal | 0x3C030487 | 0x3C03048A | flash, through the cache |
| global with initializer | 0x3FC93204 | 0x3FC93F04 | SRAM, .data |
| global without initializer | 0x3FC96B28 | 0x3FC979B8 | SRAM, .bss |
static inside a function | 0x3FC93200 | 0x3FC93F00 | SRAM, .data |
local in setup() | 0x3FCEBD1C | 0x3FCEBD1C | SRAM, loopTask stack (in the heap) |
RTC_DATA_ATTR | 0x50000200 | 0x50000200 | RTC SLOW |
RTC_NOINIT_ATTR | 0x50000204 | 0x50000204 | RTC SLOW |
malloc(100) | 0x3FCEC6A0 | 0x3FCEC180 | SRAM |
malloc(4096) | 0x3FCEC7F8 | 0x3FCEC2D8 | SRAM |
malloc(4097) | 0x3FCED8FC | 0x3C040EEC | SRAM / PSRAM |
malloc(100 KB) | 0x3FC9F3C8 | 0x3C041F70 | SRAM / PSRAM |
new uint8_t[20000] | 0x3FCD23D0 | 0x3C05B774 | SRAM / PSRAM |
heap_caps_malloc(100 KB, MALLOC_CAP_INTERNAL) | 0x3FCB8BCC | 0x3FCA024C | SRAM |
String buffer (50 characters) | 0x3FCEC714 | 0x3FCEC1F4 | SRAM |
Flash constants and PSRAM both show up at 0x3C0… addresses, in the same data-bus window: both are reached through the same cache and MMU.
RTC memory and deep sleep
In deep sleep the RTC SLOW memory stays powered, and variables placed there “for example, using RTC_DATA_ATTR” are “kept powered on by default”. ESP-IDF's esp_attr.h describes RTC_DATA_ATTR as data that “will keep its value during a deep sleep / wake cycle”.
The test sketch increments three counters on every boot and goes into deep sleep for 0.5 seconds, three times:
| Boot | Reset reason | RTC_DATA_ATTR | RTC_NOINIT_ATTR | plain global |
|---|---|---|---|---|
| 1 | power-on | 1 | 103302951 | 1 |
| 2 | deep sleep wake-up | 2 | 103302952 | 1 |
| 3 | deep sleep wake-up | 3 | 103302953 | 1 |
| 4 | deep sleep wake-up | 4 | 103302954 | 1 |
- The
RTC_DATA_ATTRcounter survives deep sleep: 1, 2, 3, 4. After a normal reset or power-on it starts again from its initial value; in the second run it was 1 again. - The plain global is reinitialized on every boot and is always 1.
- The
RTC_NOINIT_ATTRvariable also survives deep sleep, but it is not initialized: after power-on it held an arbitrary value (103,302,951 in the first run, 218,646,311 in the second).
PSRAM and the 4 KB threshold
In Arduino IDE, PSRAM is disabled by default, even if the board has it: the first item of the board menu in boards.txt is esp32s3.menu.PSRAM.disabled=Disabled. With default settings, psramFound() returns 0 and ESP.getPsramSize() returns 0 on a board with 8 MB of PSRAM. Turn it on in Tools → PSRAM → OPI PSRAM (for this board).
With PSRAM enabled, malloc quietly sends large blocks out to PSRAM. The threshold is CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL: “When allocating a size less than or equal to the threshold, the allocator will try internal memory first”, and “allocations larger than this will be done from external RAM”.
malloc(4096); // 0x3FCEC2D8 internal SRAM
malloc(4097); // 0x3C040EEC PSRAM
new uint8_t[20000]; // 0x3C05B774 PSRAM
| Setting | Threshold |
|---|---|
ESP-IDF default (Kconfig.spiram.common) | 16,384 B |
arduino-esp32 3.3.12 (precompiled sdkconfig) | 4,096 B |
So in Arduino, anything above 4 KB goes to PSRAM: malloc(4097), malloc(100 KB) and new uint8_t[20000] all did. malloc(100), malloc(4096) and the buffer of a 50-character String stayed internal. heap_caps_malloc(..., MALLOC_CAP_INTERNAL) always returns internal memory (“Memory must be internal”).
getFreeHeap() does not count PSRAM
In arduino-esp32, ESP.getFreeHeap() calls heap_caps_get_free_size(MALLOC_CAP_INTERNAL), and ESP.getMaxAllocHeap() calls heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL). With PSRAM enabled:
| Call | Bytes | Counts |
|---|---|---|
ESP.getFreeHeap() | 356,620 | internal only |
ESP.getMaxAllocHeap() | 294,900 | internal only |
ESP.getFreePsram() | 8,384,788 | PSRAM only |
heap_caps_get_free_size(MALLOC_CAP_DEFAULT) | 8,741,220 | both |
The internal heap is slightly smaller with PSRAM enabled: 392,848 bytes in total instead of 396,712. In that build the IRAM code is 3,328 bytes larger (65,280 vs 61,952), and the boundary between IRAM and data moved with it.
What a cache miss costs
Does it matter where a buffer ends up? While the data fits in the cache, PSRAM and flash are as fast as internal SRAM. The ESP-IDF docs put it this way: “frequently accessed variables in external RAM can be read and modified almost as quickly as in internal RAM”, but “when accessing large chunks of data (> 32 KB), the cache can be insufficient, and speeds will fall back to the access speed of the external RAM”.
To measure the cost of a miss, the test reads one word every 32 bytes, so every read touches a new cache line, over a buffer much larger than the cache:
A cache miss to PSRAM costs about 10× a read from internal SRAM, and a miss to flash about 24×. The documentation gives no specific figures; these are from the test board only.
| Memory | Sequential read, MB/s | Cycles per new cache line |
|---|---|---|
| internal SRAM, 256 KB | 212 | 12 |
| PSRAM, 2 MB (does not fit in the cache) | 61 | 120.5 (≈ 10×) |
flash const, 512 KB (does not fit in the cache) | 27 | 283 (≈ 24×) |
| PSRAM or flash, 16 KB, repeated pass (in the cache) | 213 | 12, same as SRAM |
- Sequential reads from SRAM are limited by the loop itself (4.5 cycles per word), not by the memory. That is why the cycles-per-cache-line column is the fairer comparison.
- The first pass over a 16 KB buffer runs at 35 MB/s from PSRAM and 27 MB/s from flash. After that the data is in the cache, and the speed equals SRAM.
memcpyof 256 KB: SRAM → PSRAM 36.9 MB/s, PSRAM → SRAM 56.7 MB/s. SRAM → SRAM (128 KB): 378 MB/s.- The read functions run from IRAM. Time is measured with
esp_cpu_get_cycle_count(); the second and third passes agree within ±1%.
The practical result: the same line of code can run at very different speeds depending on where its data lives, and with PSRAM enabled, the size of the malloc decides where a buffer goes.
What to do about it
Ask for internal memory explicitly
If a buffer has to be fast, don't leave its placement to the 4 KB threshold:
uint8_t* buf = (uint8_t*)heap_caps_malloc(32768, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
if (buf == NULL) { /* not enough contiguous internal memory */ }
Check the right number before a big allocation
ESP.getFreeHeap(): free internal memory in total.ESP.getMaxAllocHeap(): the largest block onemalloccan return from internal memory. This is the one to check before a big allocation.ESP.getFreePsram(): free PSRAM, whichgetFreeHeap()does not include.
Print your own memory map
heap_caps_print_heap_info(MALLOC_CAP_INTERNAL);
The output lists every heap region with its address, size and free space. A fragment from the test board:
At 0x3fc986b8 len 331864 free 309112 allocated 20056 min_free 79724
largest_free_block 303092 alloc_blocks 57 free_blocks 4 total_blocks 61
At 0x3fcf0000 len 32768 free 32020 allocated 0 min_free 32020
largest_free_block 31732 alloc_blocks 0 free_blocks 1 total_blocks 1
Spend IRAM deliberately
Every IRAM_ATTR function moves the IRAM/DRAM boundary towards the data and takes RAM away from your globals and heap. Use it where code has to run from RAM.
What these numbers do not cover
- Other chips. The classic ESP32, the S2 and the C3 have a different memory map. Nothing on this page was measured on them.
- Other builds. The sizes of IRAM code, globals and the main heap region depend on the core version and on what the sketch uses. Even between two builds of the same test sketch with different symbol names, the numbers differed by tens of bytes. The cache sizes and the 4 KB threshold come from the core's configuration.
- Speed. The 12 / 120 / 283 cycles were measured on one board, with OPI PSRAM and the CPU at 240 MHz.
Test setup and code
| Board | ESP32-S3 (QFN56) rev v0.2, 2 cores at 240 MHz, 16 MB flash, 8 MB OPI PSRAM |
| Core | arduino-esp32 3.3.12, board esp32:esp32:esp32s3 |
| Toolchain | arduino-cli from Arduino IDE 2.3.8 |
| Settings | defaults (PSRAM disabled) for the memory map; PSRAM=opi for the PSRAM and speed tests |
| Memory map | linker symbols, heap_caps_* calls and esp_ptr_* region checks, printed in setup() |
| Speed | read loops in IRAM, CPU cycles via esp_cpu_get_cycle_count(), three passes per buffer |
| ROM layout | the ets_rom_layout_p table read directly from the chip |
#include <esp_heap_caps.h>
#include <esp_memory_utils.h>
#include <esp_attr.h>
extern "C" { // section boundaries from the linker script
extern int _iram_start, _iram_end, _data_start, _heap_low_start;
}
const uint32_t table[256] = {1, 2, 3}; // flash
uint32_t global_init[16] = {1, 2, 3}; // SRAM, .data
uint32_t counter; // SRAM, .bss
RTC_DATA_ATTR uint32_t bootCount = 0; // RTC SLOW
void blink() { asm volatile("nop"); } // flash
void IRAM_ATTR onPulse() { asm volatile("nop"); } // IRAM
const char* region(const void* p) {
if (esp_ptr_in_rtc_slow(p)) return "RTC SLOW";
if (esp_ptr_external_ram(p)) return "PSRAM (via cache)";
if (esp_ptr_in_drom(p)) return "FLASH rodata (DROM, via cache)";
if (esp_ptr_in_iram(p)) return "internal SRAM, IRAM bus";
if (esp_ptr_in_dram(p)) return "internal SRAM, DRAM bus";
if (esp_ptr_executable(p)) return "FLASH code (IROM, via cache)";
return "?";
}
void show(const char* name, const void* p) {
Serial.printf(" %-28s %p %s\n", name, p, region(p));
}
void setup() {
Serial.begin(115200);
delay(3000);
Serial.printf("getFreeHeap=%u getMaxAllocHeap=%u\n",
ESP.getFreeHeap(), ESP.getMaxAllocHeap());
Serial.printf("iram %p..%p, data %p..%p\n",
&_iram_start, &_iram_end, &_data_start, &_heap_low_start);
uint32_t x = 1; // loopTask stack
void* m_4k = malloc(4096); // SRAM
void* m_4k1 = malloc(4097); // PSRAM, if enabled
show("blink()", (void*)&blink);
show("IRAM_ATTR onPulse()", (void*)&onPulse);
show("const uint32_t table[]", table);
show("\"hello\"", "hello");
show("uint32_t counter (bss)", &counter);
show("setup() local x", &x);
show("RTC_DATA_ATTR bootCount", &bootCount);
show("malloc(4096)", m_4k);
show("malloc(4097)", m_4k1);
free(m_4k); free(m_4k1);
// ... more objects and heap_caps_get_*_size() by capability: see the full file
heap_caps_print_heap_info(MALLOC_CAP_INTERNAL);
}
void loop() { delay(1000); }
Also: memspeed.ino (read speed of SRAM, PSRAM and flash), rtcmem.ino (RTC variables across deep sleep), romlayout.ino (dump of the ROM layout table).
Sources
- ESP32-S3 Series Datasheet v2.2, §4.1.2 “384 KB ROM: for booting and core functions” · “512 KB on-chip SRAM: for data and instructions” · “RTC FAST memory: 8 KB SRAM … It can retain data in Deep-sleep mode” · “Through high-speed caches, ESP32-S3 can support…”
- ESP32-S3 Technical Reference Manual v1.8, §15.3.2 and the Cache chapter “512 KB in total, including 32 KB Internal SRAM0, 416 KB Internal SRAM1, and 64 KB Internal SRAM2” · SRAM0 “can be allocated to either CPU or ICACHE” · SRAM2 “can be allocated to either CPU/GDMA or DCACHE” · SRAM1 “Accessed by CPU's DBUS, IBUS and GDMA at the same time” · “The size of ICache can be configured to 16 KB or 32 KB…”
- ESP-IDF v5.5: Memory Types (ESP32-S3) “If a function is not explicitly placed into IRAM … or RTC memory, it is placed into flash” · “placing a function into IRAM may reduce delays caused by a cache miss” · “By default, constant data is placed by the linker into a region mapped to the MMU flash cache” · “Any internal SRAM which is not used for Instruction RAM will be made available as DRAM”
- ESP-IDF v5.5: Support for External RAM (ESP32-S3) “The 32 MB virtual addresses are shared with flash instructions and rodata” · “External RAM uses the same cache region as the external flash” · “When allocating a size less than or equal to the threshold, the allocator will try internal memory first” · “when accessing large chunks of data (> 32 KB), the cache can be insufficient, and speeds will fall back to the access speed of the external RAM”
- ESP-IDF v5.5: Heap Memory Allocation (ESP32-S3) “some memory is allocated from the heap before the FreeRTOS scheduler is started” · “Each contiguous region of memory contains its own memory heap” · “it is probably not possible to allocate a single block of memory of this size” ·
MALLOC_CAP_INTERNAL: “Memory must be internal” - ESP-IDF v5.5: Sleep Modes (ESP32-S3) variables placed into RTC SLOW memory “(for example, using RTC_DATA_ATTR)” are “kept powered on by default”
- ESP-IDF source code v5.5.6:
components/heap/port/esp32s3/memory_layout.c,components/heap/port/memory_layout_utils.c,components/esp_common/include/esp_attr.h,components/esp_psram/Kconfig.spiram.common“ROM reserved area, recycled by heap allocator in app_main task” · “the part used by code is reserved … directly shift IRAM address to get reserved DRAM address” ·RTC_DATA_ATTR“will keep its value during a deep sleep / wake cycle” · “allocations larger than this will be done from external RAM”, default 16384 - arduino-esp32 source code 3.3.12:
cores/esp32/Esp.cpp,cores/esp32/main.cpp,boards.txt, precompiledtools/esp32s3-libs/3.3.12/sdkconfiggetFreeHeap→heap_caps_get_free_size(MALLOC_CAP_INTERNAL)·xTaskCreateUniversal(loopTask, "loopTask", getArduinoLoopTaskStackSize(), …)·esp32s3.menu.PSRAM.disabled=Disabled·CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096,CONFIG_ESP32S3_INSTRUCTION_CACHE_SIZE=0x4000,CONFIG_ESP32S3_DATA_CACHE_SIZE=0x8000,CONFIG_ARDUINO_LOOP_STACK_SIZE=8192
Video
A short video on the same topic is on the ESPSSS YouTube channel (4:25, 2026-11-17). This page goes into more detail.
Also as a YouTube Short.