static vs. dynamic memory usage in RIOT

Hi *,

in the last meeting we discussed the usage of static memory in the sixlowpan network stack. To clarify the facts I started a wiki page:

  https://github.com/RIOT-OS/RIOT/wiki/Static-vs-Dynamic-Memory

I started writing the pros and cons but there are probably more :slight_smile: Would be very helpful for beginners and residents to understand/reclaim the facts.

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

Best Christian

nice, will be useful I’m sure. Just a small remark: the term “constrained device” is less confusing than “restricted device”. Cheers Emmanuel

Hi!

     Static vs Dynamic Memory · RIOT-OS/RIOT Wiki · GitHub

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

Hey Kaspar,

just a quick remark: it's a Wiki, feel free to edit. :slight_smile:

Cheers, Oleg

Ok. You asked for it. I didn't want to, but now:

HAPPY BIRTHDAY OLEG!!!!!!

Kaspar