Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
jihe_298791
Level 2
Level 2

I’m running FreeRTOS on a PSoC 6 based PSoC 6 CY8CKIT-062-BLE. How do I determine how much heap is being used by each task (and the OS)?

0 Likes
1 Solution
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi jihe_298791​,

1. You can use the API uxTaskGetStackHighWaterMark() to query how close a task has come to overflowing the stack space allocated to it.

FreeRTOS - A FREE RTOS for small real time embedded systems

2. Using configCHECK_FOR_STACK_OVERFLOW , a compile time configuration constant within FreeRTOSConfig.h. There are two methods possible using this option.

FreeRTOS - stacks and stack overflow checking

Refer FreeRTOS documentation for details (links given above).

Regards,

Bragadeesh

Regards,
Bragadeesh

View solution in original post

0 Likes
3 Replies
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi jihe_298791​,

1. You can use the API uxTaskGetStackHighWaterMark() to query how close a task has come to overflowing the stack space allocated to it.

FreeRTOS - A FREE RTOS for small real time embedded systems

2. Using configCHECK_FOR_STACK_OVERFLOW , a compile time configuration constant within FreeRTOSConfig.h. There are two methods possible using this option.

FreeRTOS - stacks and stack overflow checking

Refer FreeRTOS documentation for details (links given above).

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes

I'm confused. Are you saying task heap is allocated on the task's stack?

0 Likes

Hi jihe_298791​,

Could you please elaborate your question?

The tasks are allocated memory based on the heap scheme that you have used.  What is the memory heap scheme have you used in your project?

For example, if you are using heap scheme 3, then the FreeRTOS scheduler uses malloc() and free() functions to allocate memory for the tasks from the heap memory of the SRAM. This task's stack holds function call return addresses, parameter values, local variables, etc.

If you are using heap_1, then the scheduler creates a single static array of size mentioned in configTOTAL_HEAP_SIZE in .bss section of the SRAM. All the tasks that you create takes memory from this region. 

Refer FreeRTOS memory management for details.

FreeRTOS - Memory management options for the FreeRTOS small footprint, professional grade, real time...

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes