Add LVGL Rust Global Allocator feature #48
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: rafaelcaricio/lvgl-rs#48
Loading…
Reference in a new issue
No description provided.
Delete branch "lvgl-alloc-feature"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #46
New optional feature that registers a Rust global memory allocator implementation that uses the LVGL memory management API. All allocations go to the LVGL managed memory location.
@ -27,0 +46,4 @@
//
#[cfg(not(feature = "lvgl_alloc"))]
use crate::mem::Box;
We could enable the LVGL side to use Rust memory allocator, if it's available and the feature "alloc" enabled in lvgl-rs. That way we wouldn't need to implement this custom
Box
implementation for that case. We would still need this implementation for cases where all features in lvgl-rs are disabled and we cannot assume that LVGL is using the same memory space.The problem is that LVGL C always support "dynamically" allocated memory backed by a static array-based backend, just like wee_alloc. LVGL-rs is a library and the choice of allocator must be made by the firmware/application developer. Besides that, the developer might decide that they don't want to have an allocator at all on their Rust firmware. LVGL C will still use their own memory management implementation.
One option is to always require users of LVGL-rs to define a global allocator in their project. This would be a limitation for some use cases?! In that scenario, we wouldn't need the code in
mem
module at all, since the memory space would be shared by LVGL C and Rust.