Heap algorithm
Hi,
which heap algorithm does CrossWorks for MSP430 use when I use the standard C functions malloc and free?
Secondly, it seems that when I set the heap size to let's say 200 bytes, these 200 bytes are allocated in the RAM memory (section IDATA0) which is ok, but also in the flash memory (CONST section, data_init part). The heap can be unitialized, so why these 200 bytes in the CONST section? Or is it possible to set to C heap to be uninitilaized?
Thanks, Marek
-
CrossWorks uses a best-fit strategy for the heap. And yes, in order to set the heap up, you do need initialized data, but it's possible that we may change that in the future. For real-time response, the default heap strategy may not be the best for you, in which case use a binary or Fibonacci buddy heap. In a future CrossWorks release, we will offer multiple heap implementations as well as multiple simultaneous heaps. I have already implemented the binary buddy heap.
-
If my understanding of the heap algorithms is correct, you usually need only a few bytes of data in the heap to be initialized (the variables that you use to keep track of the free memory), so it might be a waste of flash memory to initialize the full heap to the needed data and zero the rest; a heap_init functions might do the trick as well (though I can use some external code if I need this feature).
I will have a look at the other memory allocation algorithms, thanks for the tip.
The possibility to choose another heap algorithm seems interesting..
Please sign in to leave a comment.
Comments
2 comments