Calculating Heap and retained RAM

2 posts / 0 new
Last post
ArminL
Offline
Last seen:3 years 11 months ago
Joined:2016-09-30 07:23
Calculating Heap and retained RAM

Hi Dialog,

1.
my custom application based on multi-link demo.
In SDK 1.0.6 heap size is
#define configTOTAL_HEAP_SIZE 13312 /* This is the FreeRTOS Total Heap Size */
In SDK 1.0.8.1 heap size is
#define configTOTAL_HEAP_SIZE 9216 /* This is the FreeRTOS Total Heap Size */

Why are there different sizes in these two SDKs for the same project? How can I calculate heap size for my custom application?

2.
How much retained RAM is required by the SDK?

Thanks
Armin

Device:
MT_dialog
Offline
Last seen:1 month 3 days ago
Staff
Joined:2015-06-08 11:34
Hi ArminL,

Hi ArminL,

1. The additional heap size on the older SDK is due to additional optimizations performed on the 1.0.8 that reduce the Free RTOS heap usage of the SDK. Regarding how to calculate your heap this is done empirically by configuring the system with a big heap and then by measuring the Heap ratio usage while executing the final application. FreeRTOS provides methods of monitoring the Heap Usage, like the xPortGetFreeHeapSize(), this will return the total amount of heap space that remains unallocated and also you can check the xPortGetMinimumEverFreeHeapSize(). Also there is an implementation for heap monitoring in the ble_adv demo that is enabled by defining the dg_configTRACK_OS_HEAP and essentially forces the system to assert if any task surpass a specific amount of heap usage.

2. In the retained RAM is stored all the essentials for the BLE stack like the heap (messages / enviroment / dbheap), retained variables and functions used by the SDK etc and of course the heap of the Free RTOS, there is not an exact amount of space that i can mention but you can either build your project by defining an RTOS heap to 0 and check the .map file and add the amount of memory in the retained spaces, or you can check the .map file and just subtract the OS heap size from the total size of your retained RAM. For example in the ble_adv demo the amount of retained data is about 48K.

Thanks MT_dialog