CarletonURocketry / fetcher

A QNX process for fetching data from sensors over I2C.
https://carletonurocketry.github.io/fetcher/
MIT License
1 stars 0 forks source link

Arena allocation #19

Closed linguini1 closed 7 months ago

linguini1 commented 7 months ago

We want to avoid allocating using the heap in case this program needs to be ported to a fully embedded system. However, allocating sensor contexts on the stack can use a lot of stack space since some contexts are quite large. Instead of doing this, a static buffer should be defined called an arena.

As sensors are created/initialized, the space required to store their contexts should be allocated from this arena instead of on the stack. This way we don't have a stack overflow.

Read more about arena allocators here. This article goes very in-depth about memory management.