#memory #manager #micro-controller #no-std

nightly no-std defrag

safe and low overhead defragmenting memory manager for microcontrollers

5 releases

Uses old Rust 2015

0.1.4 May 31, 2017
0.1.3 Sep 16, 2016
0.1.2 Sep 16, 2016
0.1.1 Sep 4, 2016
0.1.0 Sep 4, 2016

#1285 in Embedded development

MIT license

86KB
1.5K SLoC

Build Status

defrag: safe and efficient memory manager for microcontrollers

This library is in the Beta stage 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.

Docs

See the library documentation at https://docs.rs/defrag

Issues

If you find any bugs or have a feature requests, submit them to:

https://github.com/vitiral/defrag-rs/issues


lib.rs:

defrag: safe and efficient memory manager for microcontrollers

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.

How it works

The primary manager of memory is the Pool, from which the user can call Pool.alloc::<T>() or Pool.alloc_slice::<T>(len). From this they will get a Mutex<T> like object which behaves very similarily to rust's stdlib Mutex.

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 Mutex does not implement Send or 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.

Dependencies