cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 6 MCU

New Contributor

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
Reply
1 Solution
Moderator
Moderator

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
Reply
3 Replies
Moderator
Moderator

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
Reply
New Contributor

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

0 Likes
Reply
Moderator
Moderator

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
Reply
Top labels