I was just asked how much memory my ESP32 setup has/uses. I was pretty sure it’s 8MB. But a quick test gave this:
>>> import gc
>>> gc.mem_free()
1448816
>>> gc.mem_alloc()
2649536
I thus looked into the MP code and found this:
switch (esp_spiram_get_chip_size()) {
case ESP_SPIRAM_SIZE_16MBITS:
mp_task_heap_size = 2 * 1024 * 1024;
break;
case ESP_SPIRAM_SIZE_32MBITS:
case ESP_SPIRAM_SIZE_64MBITS:
mp_task_heap_size = 4 * 1024 * 1024;
break;
So even with 8MB RAM detected the heap is limited to 4MB. Is there a reason for that?