Not enough DMA-able memory to allocate display buffer

One more thing you can do is change the factor parameter to 8 or to 16.
This parameter controls what factor of the screen is buffered, so larger number means smaller buffer (and possibly lower performance).

Actually, even if there is enough memory, there might not be enough DMA-able RAM.
Not all RAM is DMa-able on ESP32, only about 328KB.
image
This DMA-able RAM is probably consumed by the WiFi driver.

Here are some things you can try:

  • Try to initialize the ili9341 driver before importing and using WiFi, so it would be the first one to allocate DMA-able RAM. WiFi will have less, but perhaps enough RAM.
  • Change WiFi RAM allocation configuration. There are probably some H files or other configuration files that control this (that would probably require rebuilding the firmware).

You can check how much DMA-able RAM you have with the heap_caps_print_heap_info function. I think it’s available on espidf module so you can call it from a Micropython script or REPL.