Re: STL containers and managing memory allocation in embedded systems



On 31 Mar 2006 13:32:07 GMT, Hans-Bernhard Broeker
<broeker@xxxxxxxxxxxxxxxxxxxxx> 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.

If you can't afford to allow exception handling, you generally can't
allow C++ style dynamic memory handling. It's as easy as that.

How can one manage that?

Primarily by not doing it.

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

Primarily by not using them.

Seems too radical.

An embedded system may use perfectly dynamic memory as long as it is
able to recover from lack of memory or,at least, not enter an unstable
state. Some Denial-Of-Sservice may be allowed as long as the whole
system continues to work.

The main problem is that *every* allocation must be checked, wheteher
with exceptions or with null pointer return.

I am now working on one embedded system, and it *must* use some kind
of memory management, so as to balance resources between different
parts of the program. As I am compiling with GCC, exception throwing
is a definite no-no, becuase it neraly doubles the space used by code.

But everything works fine by using no-throw new operator and checking
its result. BTW, I am also making some test on using STL allocators to
optimize some parts of the system, spceially the multhreaded C++
kernel.

Zara

.



Relevant Pages

  • Re: Secure C library
    ... ] Yesterday Samsung announced a flash memory of 16GBit. ... ] Embedded system with several MB of memory will be common place ... in small quantities, since they are not standard, just like buying a 1MB disk drive NOW is almost impossible, but buying a 120GB is trivial. ... Using standard PC components lowers the cost in our situation, ...
    (comp.std.c)
  • Re: Is microblaze able to change heap_size?
    ... What evidence do you have that malloc() is not working, ... stack space, rather than heap space. ... some software from a PC environment to an embedded system, ... programmers are extremely lazy about memory management and will happily ...
    (comp.arch.fpga)
  • Re: Physical to virtual address mapping
    ... Embedded system consisting one processor, SDRAM and some set of Buses. ... The communication happens through memory map IO. ... If you are running in a completely physical-address model (colloquially ...
    (comp.realtime)
  • Re: Memory management strategy
    ... >The goal is efficient utilization of small amount of memory - means - ... >allocation for fixed length blocks / variable length blocks. ... - Avoid recursive functions, if you can. ... to some mass storage device (if your embedded system has one) if the ...
    (comp.lang.c)
  • Re: CF Bug / Limitation in XMLTextWriter (OutOfMemory)
    ... Your desktop can page memory to and from disk as needed in order to fulfill ... and code for the fact that an allocation request ... I've been doing embedded system development for the better part of 10 ...
    (microsoft.public.dotnet.framework.compactframework)