Re: STL containers and managing memory allocation in embedded systems



Hans-Bernhard Broeker wrote:
In comp.arch.embedded Alex Vinokur <alexvn@xxxxxxxxxxxxxxxxxxxxx> wrote:

The memory allocation issue in embedded systems is usually critical..

It's usually beyond critical --- it's inacceptable, period. An
embedded system has nobody to complain to if an operation as strictly
internal as a memory allocation fails. So it had better not go there
at all.

That's a bit overkill - not all embedded systems are 100%
mission-critical.
I.e. you might have a system logger, a configuration deamon etcetera.
Sure,
it would be annoying if they failed, but the watchdog can restart them
once
the critical parts are done using all memory.

Of course, the parts that ARE critical will be designed such that no
memory allocation ever fails.

2. But how to manage memory allocation in containers for embedded
systems?

Primarily by not using them.

Used to be true for 512 byte, single function embedded systems. Doesn't
matter so much for 512 Megabyte systems today, where the critical
functions need 200 Mb max.

Remember: even on real-time systems, being faster may be useful, and
using
dynamically allocated memory is a good way to achieve that (e.g. for
caches)

HTH
Michiel Salters

.