Failed to allocate memory after integrating algorithm library。

Learn MoreFAQsTutorials

9 posts / 0 new
Last post
xuguodong
Offline
Last seen:1 month 2 weeks ago
Joined:2020-06-04 13:34
Failed to allocate memory after integrating algorithm library。

Hi Dialog,

Failed to allocate memory after integrating algorithm library。

Our algorithm only need total ram 9kBytes(data 1.5k bss 7.5k).

After setting the following two parameters, the issue still exists: Malloc fail.

  1. Set theconfigTOTAL_HEAP_SIZE from 11200 to25*1024.
  2. When OS_TASK_CREATE, set stack from 756 to 1024*22.

I attached my analysis, pls help me check more.

Thanks.

Device:
PM_Dialog
Online
Last seen:4 min 33 sec ago
Staff
Joined:2018-02-08 11:03
Hi xuguodong,

Hi xuguodong,

The vApplicationMallocFailedHook() is a hook to the FreeRTOS. This hoot notifies the application when there is not enough continuous heap available for the attempted memory allocation. I would recommend increasing the size of the FreeRTOS heap (configTOTAL_HEAP_SIZE in custom_config_XXXX.h file) to the max number the code compiles.

Thanks, PM_Dialog

xuguodong
Offline
Last seen:1 month 2 weeks ago
Joined:2020-06-04 13:34
Hi Dialog,

Hi Dialog,

what is the max size of the FreeRTOS heap (configTOTAL_HEAP_SIZE)?

what is the max size of task stack size ?

Thanks.

PM_Dialog
Online
Last seen:4 min 33 sec ago
Staff
Joined:2018-02-08 11:03
Hi xuguodong,

Hi xuguodong,

You could use heap size as big as you want. If the system is running out of RAM, the linker will issue an error. Please refer tohttps://freertos.org/for more information on FreeRTOS.

Thanks, PM_Dialog

xuguodong
Offline
Last seen:1 month 2 weeks ago
Joined:2020-06-04 13:34
Hi Dialog,

Hi Dialog,

Set task stack size to >1024*10, error: Failed to allocate memory will occur.

Thanks.

PM_Dialog
Online
Last seen:4 min 33 sec ago
Staff
Joined:2018-02-08 11:03
Hi xuguodong,

Hi xuguodong,

Can you please attach a screenshot? What is the configTOTAL_HEAP_SIZE that you are using?

Thanks, PM_Dialog

xuguodong
Offline
Last seen:1 month 2 weeks ago
Joined:2020-06-04 13:34
As follow, if task stack > 10

As follow, if task stack > 10*1024, memory failed to allocate.

/*************************************************************************************************\
* Memory specific config
*/
#德fine dg_configQSPI_CACHED_OPTIMAL_RETRAM_0_SIZE_AE ( 64 * 1024)
#德fine dg_configQSPI_CACHED_RAM_SIZE_AE ( 32 * 1024)
#德fine dg_configQSPI_CACHED_RETRAM_0_SIZE_AE ( 96 * 1024)

#德fine dg_configQSPI_CACHED_RAM_SIZE ( 56 * 1024)
#德fine dg_configQSPI_CACHED_RETRAM_0_SIZE ( 72 * 1024)
#德fine dg_configQSPI_CODE_SIZE ( 256 * 1024)

OS_TASK_CREATE("PXP Reporter", /* The text name assigned to the task, for
debug only; not used by the kernel. */
pxp_reporter_task, /* The function that implements the task. */
NULL, /* The parameter passed to the task. */
#if (dg_configDISABLE_BACKGROUND_FLASH_OPS == 1)
512年,/ *分配的字节数
stack of the task. */
#else
#if ZSENS_FUSION_ALGO
1024*10, /* The number of bytes to allocate to the
stack of the task. */
#else
756,
#endif
#endif

xuguodong
Offline
Last seen:1 month 2 weeks ago
Joined:2020-06-04 13:34
/****************************

/*************************************************************************************************\
* Memory specific config
*/
#德fine dg_configQSPI_CACHED_OPTIMAL_RETRAM_0_SIZE_AE ( 64 * 1024)
#德fine dg_configQSPI_CACHED_RAM_SIZE_AE ( 32 * 1024)
#德fine dg_configQSPI_CACHED_RETRAM_0_SIZE_AE ( 96 * 1024)

#德fine dg_configQSPI_CACHED_RAM_SIZE ( 56 * 1024)
#德fine dg_configQSPI_CACHED_RETRAM_0_SIZE ( 72 * 1024)
#德fine dg_configQSPI_CODE_SIZE ( 256 * 1024)
/*************************************************************************************************\
* FreeRTOS specific config
*/
#德fine OS_FREERTOS /* Define this to use FreeRTOS */
#if (dg_configUSE_SOC)
#if defined(DEBUG_SOC)
#德fine configTOTAL_HEAP_SIZE 12300 /* This is the FreeRTOS Total Heap Size */
#else
// #define configTOTAL_HEAP_SIZE 11200 /* This is the FreeRTOS Total Heap Size */
#德fine configTOTAL_HEAP_SIZE 20*1024 /* This is the FreeRTOS Total Heap Size */
#endif
#else
#德fine configTOTAL_HEAP_SIZE 11000 /* This is the FreeRTOS Total Heap Size */
#endif

PM_Dialog
Online
Last seen:4 min 33 sec ago
Staff
Joined:2018-02-08 11:03
Hi xuguodong,

Hi xuguodong,

Does the system still run out of heap?

Thanks, PM_Dialog