how to check remaining heap size
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-07 6: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.
- Labels:
-
STM32H7 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-07 6: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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-07 7: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/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-08 5:25 AM
Best is to avoid dynamic allocation during runtime and only use it with setup...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-08 5: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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-10-28 7:11 PM
OK, thanks for the suggestion.
