Could not allocate required memory

Hi,

After adding ANCS client service to my firmware, firmware crashed.

Investing I could see it was failing to allocate memory

File: task.c

Line no: 2012

else
{
/* This line will only be reached if the kernel could not be started,
because there was not enough FreeRTOS heap to create the idle task
or the timer task. */
configASSERT( xReturn != errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY );

I tried to optimize the code, but still the error didn't get resolved.

I tried to increase the heap size, earlier it was ( 2*4096). 

#define configTOTAL_HEAP_SIZE                                                     ( 3*4096 )

After this change firmware didn't crash after flashing.

Please let me know if this is the correct fix. 

Thanks,

Parents
  • This error most likely occurred when you created a new task. The memory for task structure is created from the heap and the solution you proposed is correct one. Except that you do not need to allocate so much of the heap, just increase heap by few hundred bytes until this error does not occur. Allocating three full pages for heap seems to be wasting a lot of heap memory.

Reply Children
No Data
Related