lgalloc
This library provides a memory allocator for large objects.
[]
= { = "https://github.com/antiguru/rust-lgalloc" }
Example
use Region;
Details
- Lgalloc provides an allocator for power-of-two sized objects. Regions encapsulate objects
as a
Vec<T>. - Although a region provides mutable access to a
Vec<T>, the caller has to make sure that the vector is never re-allocated, i.e., never push or extend with more data than the remaining capacity. - Memory is not unmapped, but can be lazily marked as unused with a background thread. The exact options for this still need to be determined.
- The allocations are mapped from a file, which allows the OS to page without using swap.
- On Linux, this means it can only handle regular pages (4KiB), the region cannot be mapped with huge pages.
- The library does not consume physical memory when all regions are freed, but pollutes the virtual address space because it doesn't unmap regions. This is because the library does not keep track what parts of a mapping are still in use.
- Generally, use at your own risk because nobody should write a memory allocator.
- Performance seems to be reasonable, similar to the system allocator when not touching the data, and faster when touching the data. The reason is that this library does not unmap its regions.