2020-10-07 06:06 PM
We are using stm32h750xb for our project running uC/OS-II RTOS.
Question: is there a way to check the remaining heap size for the system at any point of time after the product is up and running.
2020-10-07 06:58 PM
It is usually a linked list, walk it and understand the arena.
The exact implementation will be compiler/library specific, but is not complicated. Usually you'll find the linking structures below the address returned by malloc(), with initial heap pointers exposed as symbols.
2020-10-07 07:07 PM
We are using the IAR Embedded Workbench for ARM. And the ‘malloc()’ function is actually calling ‘__iar_dlmalloc()’. I believe IAR is using the Doug Lea's Memory Allocator.
I found the below technical note on IAR web site. Anyone has experience of using ‘__iar_dlmallinfo()’ and ‘__iar_dlmalloc_stats()’ mentioned in the technical note ?
https://www.iar.com/support/tech-notes/general/iar-dlib-library-heap-usage-statistics/
2020-10-08 05:25 AM
Best is to avoid dynamic allocation during runtime and only use it with setup...
2020-10-08 05:43 AM
Indeed, it can work for initial allocations based on user configuration or mode of operation settings, rather than compile time statics.
I think however it is important to understand basic CS concepts like heaps and linked lists, and have an awareness of how they work, and the issues with fragmentation and resource leaks.
In the last uCOSII design I worked on we needed some dynamic allocation of resources, and used a memory pool with various sized objects to manage that. And did a lot of testing, analysis and reporting to identify resource leaks, as the devices were expected to run continuously for years.
2020-10-28 07:11 PM
OK, thanks for the suggestion.