This library is in the Beta release and is subject to change
This library aims to bring safe heap memory management to microcontrollers. Combined with rust's excellent type system and borrow checker, creating complex applications with limited resources is easier than it has ever been before.
The possibility of fragmentation is the primary reason that dynamic memory allocation is not used on microcontrollers. defrag, as the name implies, is able to defragment memory -- giving your embedded application power, reliability and simplicity. Also, the overhead of each allocated block is only 8bytes, so allocations are very cheap.
The primary manager of memory is the
Pool, from which the user can call
Pool.alloc_slice::<T>(len). From this they will get
Mutex<T> like object which behaves very similarily to rust's stdlib
When the data is not locked, the underlying pool is allowed to move it in order
to solve potential fragmentation issues.
pool.clean() combines contiguous
free blocks and
pool.defrag() defragments memory. In addition, there are
various strategies for utilzing freed blocks of memory.
Note: This library is intended only for (single threaded) microcontrollers, so it's
Mutexdoes not implement
Sync(it cannot be shared between threads). Depending on what kind of architectures or OS's spring up on uC rust code, this may change.
The Block is the smallest unit of allocation allowed. It is currently equal to 16 bytes
All allocated data is represented as some kind of a Mutex. When the data
is unlocked, the underlying
A value which can be used through
memory error codes