In my current project developed on WROVER KIT V3, I need a large and fast memory buffer. Testing with buffer allocated on external RAM, speed was not enough and timing was not deterministic. I guess since the PSRAM bus is shared with SPI FLASH, this makes sense/ Since the project is about converting a stream format to another in realtime streaming, this is not a trade-of I can make.I though it would be best to use internal RAM and assumed that the 520K of internal RAM would have some of the space taken up by FreeRTOS and other base services, but a good amount would be still available for my use.
The project I have here, comes from the esp32 template with very few stuff added. At the very early stage of app_main(), I called 'heap_caps_print_heap_info( MALLOC_CAP_INTERNAL );' to see what memory I have left. The result is not what I expected. Here I quote from terminal:
I would expect that since I print the report at startup, not many malloc/free have run and the reserved memory would be close to start of IRAM, leaving a large block free at the bottom. Also this total (289568 + 22316 ) is much much less than 520K. I suppose part of the IRAM is given for IRAM_ATTR functions? or maybe I don't understand well the memory layout... or I could configure the SDK to use more (or all) or the IRAM as heap.Heap summary for capabilities 0x00000800:
At 0x3ffae7e4 len 2047 free 120 allocated 1844 min_free 120
largest_free_block 120 alloc_blocks 11 free_blocks 1 total_blocks 12
At 0x3ffae6e0 len 6432 free 4 allocated 6288 min_free 4
largest_free_block 4 alloc_blocks 26 free_blocks 1 total_blocks 27
At 0x3ffbc898 len 145256 free 130988 allocated 14184 min_free 130028
largest_free_block 130988 alloc_blocks 12 free_blocks 1 total_blocks 13
At 0x3ffe0440 len 15296 free 15260 allocated 0 min_free 15260
largest_free_block 15260 alloc_blocks 0 free_blocks 1 total_blocks 1
At 0x3ffe4350 len 113840 free 113804 allocated 0 min_free 113804
largest_free_block 113804 alloc_blocks 0 free_blocks 1 total_blocks 1
At 0x40098d0c len 29428 free 29392 allocated 0 min_free 29392
largest_free_block 29392 alloc_blocks 0 free_blocks 1 total_blocks 1
free 289568 allocated 22316 min_free 288608 largest_free_block 130988
Looking at the tech-reference there should be 3 blocks of IRAM:SRAM 0 (192 KB), Internal SRAM 1 (128 KB), and
Internal SRAM 2 (200 KB).
In this report I can see 2 large blocks, the ones I marked bold in the report. Also I cant see why there are small pieces reserved on all blocks. In such an early stage that I call the report, I would expect that all memory reserved would be coming from the first block (SRAM0?), but here fragmentation is already evident.
Can you help me explain how I control and solve this situation?