Page 1 of 1

Maximum memory allocation

Posted: Thu Jul 26, 2018 10:18 am
by Deouss
I am struggling with data allocation for LCD buffer which is 640x480/16bit or 320x240/16.
Question - what is the maximum memory chunk I can allocate on ESP?
I recently bought 16Mb ESP modules with 8Mb psram.

I use malloc() however it fails - Guru med or invalid ptr.

I am receiving data with socket so additional question is how large buffer can socket handle?
What do you advise?

Thank you

Re: Maximum memory allocation

Posted: Thu Jul 26, 2018 12:13 pm
by Vader_Mester
For heap allocation read this. I think it's better to use these functions.
https://esp-idf.readthedocs.io/en/lates ... alloc.html

There is an option in Menuconfig to enaple Heap allocation in SPI RAM.
Image

Re: Maximum memory allocation

Posted: Thu Jul 26, 2018 12:44 pm
by Deouss
Hey, appreciate your help! Big thanks!
I will try to transfer bitmap directly to spi through socket)

Re: Maximum memory allocation

Posted: Thu Jul 26, 2018 11:40 pm
by Deouss
I wanted to update on the heap memory allocation if anyone is interested.
With the second option 'Make ram allocatable using heap_caps...' it was possible to allocate around 4Mb SPI ram I'm guessing external on Wrover. I had issues with switching to Wroom and flashing - error 'failed to init external ram'.
I used MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT
heap_caps_get_largest_free_block() on wroom reports around 1.5Mb free ram to use. Expected much more.
Maybe in new framework something will be improved )

Re: Maximum memory allocation

Posted: Fri Jul 27, 2018 2:21 am
by Vader_Mester
Deouss wrote:I wanted to update on the heap memory allocation if anyone is interested.
With the second option 'Make ram allocatable using heap_caps...' it was possible to allocate around 4Mb SPI ram I'm guessing external on Wrover. I had issues with switching to Wroom and flashing - error 'failed to init external ram'.
I used MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT
heap_caps_get_largest_free_block() on wroom reports around 1.5Mb free ram to use. Expected much more.
Maybe in new framework something will be improved )
Well the Wroom failed cause it does not ha a SPI RAM. It only has Flash. Only Wrover modules have RAM.
Some people have found a way to circumvent the need to change menuconfig between modul switching i'll look for the topic.

Wroom should not indicate more than a 2-300kB RAM as it has no external.