[chbot] Heaps and heaps of storage

Charles Manning cdhmanning at gmail.com
Mon Jul 1 23:54:53 BST 2013


As a general principle, I share your disdain of malloc and cronies in 
embedded.

These functions are not at all predictable in their performance and 
reliability. With time, vast amounts of malloc/free can cause memory 
fragmentation which can, in turn, cause all sorts of "interesting" 
behaviours. This is particularly true of the simplistic memory allocators 
used in many embedded systems.

IMHO, well not so humble opinion, it is safe to use malloc etc to allocate 
storage which is then managed by a code body as a "pool" or resources for 
that code body. This does not cause memory fragmentation and reduces the 
number of malloc calls by a buge amount.

For example, consider some code to handle a network protocol. Buffers could be 
created and released on the fly with malloc()/free(), or you could allocate a 
pool of buffers and then get then from the buffer or release them back to the 
buffer when done.




On Tuesday 02 July 2013 10:38:46 Mark Atherton wrote:
> <http://www.embedded.com/design/programming-languages-and-tools/4416457/EMB
>-tm-6-15-13-Dynamic-memory-and-heap-contiguity>http://www.embedded.com/desig
>n/programming-languages-and-tools/4416457/EMB-tm-6-15-13-Dynamic-memory-and-
>heap-contiguity
>
>
> a while ago, someone at the group looked at me sideways when I
> expressed my disdain about the use of heaps, malloc(), free() etc. in
> an embedded environment.
>
> this article covers some of the issues, along with some new ideas.
>
> -Mark
>
>
>
> _______________________________________________
> Chchrobotics mailing list Chchrobotics at lists.linuxnut.co.nz
> http://lists.ourshack.com/mailman/listinfo/chchrobotics
> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
> Web site: http://kiwibots.org
> Meetings 3rd Monday each month at Tait Radio Communications, 175 Roydvale
> Ave, 6.30pm
>
> When replying, please edit your Subject line to reflect new content.





More information about the Chchrobotics mailing list