Question of the Week: Do you use or allow dynamic memory allocation in your embedded design?
Back when I was deep into building embedded control systems (and snow was always 20 feet deep and going to and from school was up hill both ways), the use of dynamic memory allocation was forbidden. In fact, using compiler library calls was also forbidden in many of the systems I worked on. If we needed to use a library call, we rewrote it so that we knew exactly what it did and how. Those systems were highly dependent on predictable, deterministic real-time behavior that had to run reliably for long periods of time without a hiccup of any kind. Resetting the system was not an option, and often the system had to keep working correctly in spite of errors and failures for as long as it could – in many cases lives could be on the line. These systems were extremely resource constrained both from a memory and processing duty-cycle time perspective and we manually planned out all of the memory usage.
That was then, this is now. Today’s compilers are much better than they were then. Today’s processors include enormous amounts of memory and peripherals compared to the processors back then. Processor clock rates support much more processing per processing period than before such that there is room to waste a few cycles on “inefficient” tasks. Additionally, some of what were application-level functions back then are low-level, abstracted function calls in today’s systems. Today’s tools are more aware of memory leaks and are better at detecting such anomalies. But are they good enough for low level or deeply embedded tasks?
Do today’s compilers generate good enough code with today’s “resource rich” microcontrollers to make the static versus dynamic memory allocation a non-issue for your application space? I believe there will always be some classes of applications where using dynamic allocation, regardless of rich resources, is a poor choice. So in addition to answering whether you use or allow dynamic memory allocation in your embedded designs, please share what types of applications your answer applies to.
To make tracking the different series easier, I have three series running at this time. Monday posts address the Robust Design series. Wednesday posts address the Question of the Week series. Friday posts address the Extreme Processing Thresholds series.
To make following the Question of the Week series easier (especially with multiple overlapping series), I am including the index below to previous relevant posts. I encourage you to check out all of the posts for the question of the week series; maybe they will inspire you to share your observations. I would love to be able to consolidate different perspectives and lessons learned here. I suspect there are some valuable lessons to be gleaned from comparing such stories. If you would like to suggest a question, please contact me.
2010, March 17: Question of the Week: You know you’re an embedded developer when …
KjellKod commented:
KjellKod commented:
embeddeddesigner commented:
embeddeddesigner commented:
Brian S commented:
Brian S commented:
Glenn Edgar commented:
Glenn Edgar commented:
Phil Ouellette commented:
Phil Ouellette commented:
Andy T commented:
Andy T commented:















