Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added docs on static and dynamic memory #1212

Merged
merged 1 commit into from
Feb 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions docs/development/memory_management.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ The RAM is a limiting resource and has to be managed to be used as efficiently a

## Static VS dynamic allocation

TBD
Static memory allocation is done at compile time and the build system checks that the amount of memory that is required
actually is available in the Crazyflie. Dynamic memory on the other hand, is requested and allocated in runtime using
the `malloc()` function. Dynamic memory allocation may fail (if there is not enough memory) and the error must be
handled in some way (currently by failing an assert which will reboot the Crazyflie).

In the Crazyflie firmware, we prefer static allocation over dynamic, mainly because it is checked at compile time and no
more error handling is required. Some calls to FreeRTOS do allocate a limited amount dynamic of RAM, but this is usually done
in the initialization phase and out of memory conditions should be detected quickly when booting the system.

## Static allocation

Expand Down Expand Up @@ -76,4 +83,4 @@ macro instead.

Code that uses DMA through a public API should verify verify that pointers
passed in through the API do not point to CCM. Use `ASSERT_DMA_SAFE` for this
pupose to fail fast and indicate what the reason for the failued is.
purpose to fail fast and indicate what the reason for the failed is.