8 releases (4 breaking)
0.5.2 | Jun 22, 2021 |
---|---|
0.5.1 | Oct 29, 2020 |
0.4.0 | Sep 20, 2020 |
0.3.0 | Sep 19, 2020 |
0.1.0 | Aug 4, 2020 |
#448 in Memory management
23 downloads per month
79KB
1.5K
SLoC
redox-buffer-pool
A small library that provides a general-purpose O(log n)-for-the-most-part memory allocator, suitable for small (32-bit at the moment) and possibly short-lived allocations. It also comes with a "guarding" mechanism, which will prevent the pool from reclaiming memory if it's in use by someone else.
While the name of this crate begins with Redox, it can be used on other
operating systems as well; the
redox_syscall crate is only used with
the redox
feature enabled, and all it does is adding some error code conversion.
lib.rs
:
redox-buffer-pool
This crate provides a buffer pool for general-purpose memory management, with support for allocating slices within the pool, as well as expanding the pool with potentially non-adjacent larger underlying memory allocations, like mmap(2) or other larger possible page-sized allocations.
The current allocator uses one B-trees to partition the space into regions either marked as occupied or free. The keys used by the B-tree have a custom comparator, which ensures that keys for used ranges are orderered after the keys for free ranges. This, together with having a free space tree, makes acquiring buffer slices possible in O(log n), provided that there is already an aligned range (otherwise, it simply does linear search in O(n) until it finds a range large enough to account for the misalignment).
Dependencies
~75–445KB