calloc fails even when free heap is large enough

Jami17
Posts: 20
Joined: Wed Jul 12, 2017 10:55 pm

calloc fails even when free heap is large enough

Postby Jami17 » Thu May 09, 2019 12:21 pm

On a ESP-CAM module with external RAM this allocation fails
p= calloc(80, 240);

This smaller request works ok:
p= calloc(60, 240);


But these functions report that there's sufficient heap space available:
xPortGetFreeHeapSize(): 3456208
heap_caps_get_largest_free_block(MALLOC_CAP_8BIT): 3426256


Why does calloc fail even when there's enough RAM available?

Is there a workaround available?

I am using: ESP-IDF v3.3-beta2-18-g0f927791b-dirty

chegewara
Posts: 2230
Joined: Wed Jun 14, 2017 9:00 pm

Re: calloc fails even when free heap is large enough

Postby chegewara » Thu May 09, 2019 6:11 pm

Check options in menuconfig about how psram should be added to heap, because not always memory can be with calloc.
Also try to use:

Code: Select all

 heap_caps_malloc(..., MALLOC_CAP_SPIRAM)   
 

Jami17
Posts: 20
Joined: Wed Jul 12, 2017 10:55 pm

Re: calloc fails even when free heap is large enough

Postby Jami17 » Sat May 11, 2019 9:02 pm

That did it !
Thank you very much.

Who is online

Users browsing this forum: No registered users and 188 guests