emma is a full-fledged allocator written in pure rust that is intended to not rely on anything in the target process. This means:
- Fully
no_stdcompatible. - No direct or indirect usage of
libc(or any other non-rust library):emmauses raw syscalls instead. - No usage of shared resources: Instead of
brk/sbrkto modify the shared data segment,emmaonly ever maps its own segment(s) usingmmap.
This means that multiple emma instances can be used in the same process without ever noticing one another.
Performance
emma seems not far behind (other) state-of-the-art allocators.
Target Architecture
At the moment, emma exclusively targets linux on x86_64.
Known Issues
- It is not clear how
emmabehaves when a process is forked. (Note: child processes of multi-threaded processes may only access async-signal-safe functions until they callexecveanyway.) - If a thread is terminated during memory de-/allocation (terminating a thread at any other time in any way does not bother
emma):tlsdisabled: The heap may end up permanently locked, deadlocking other threads.tlsenabled: The heap may get corrupted as soon as another thread acquires the per-thread-heap from the dead thread.
- Embedding multiple
emmas into one process should work, but unless their symbols are renamed they may share data structures behind the scenes. - An
emmainstance does not return all its resources, even if all allocations are returned. This is reasonable for a global allocator, but makes it not as useful as a temporary allocator. emmais not async-signal-safe, i.e., you may not de-/allocate memory in a signal handler. (The same probably holds true for your default memory allocator; POSIX does not listmallocorfreeas async-signal safe either.)
Features
tlsenabling thread-local-storage requires a nightly compiler. Enablingtlsmassively increases performance.boundary-checksenables assertions at the library boundary. These assertions cost a small amount of performance.
License
Licensed under either of:
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Contributions
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.