[riot-devel] static vs. dynamic memory usage in RIOT

Kaspar Schleiser kaspar at schleiser.de
Fri Jan 17 11:42:26 CET 2014


Hi!

On 01/16/2014 09:12 PM, Christian Mehlis wrote:
>      https://github.com/RIOT-OS/RIOT/wiki/Static-vs-Dynamic-Memory
Nice!

> Hope you guys and girls can add more points to the list.

Some remarks:

- I think the first "pro" for static memory is confusing.
*accessing* the memory is always constant. *allocating* it is the 
problem for dynamic memory regarding realtime properties.

- I'd add a distinction between stack and global scope static memory.

- Dynamic memory *cannot* be relied on. Failure to allocate must be 
dealt with.

- The core is designed to be "malloc free" in order to stay real-time 
capable.

- You already mention that there's no "free". Stress that point. It 
means code using dynamic memory is not really portable. We support it 
for simplicity reasons and because we can, but when we'll define a base 
line of supported stuff that is supposed to be working on *all* 
platforms, everything using malloc will be out.


The system *should* work even if all threads preallocate all the memory 
they might maximally use. If you don't have enough memory then, you 
could run into out-of-memory conditions at runtime which are not so easy 
do deal with.

In short, try to avoid dynamic memory as much as possible.

Cheers!
Kaspar


More information about the devel mailing list