Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aldantanneo/dodgems
A simple bump allocator library
https://github.com/aldantanneo/dodgems
Last synced: 24 days ago
JSON representation
A simple bump allocator library
- Host: GitHub
- URL: https://github.com/aldantanneo/dodgems
- Owner: AldanTanneo
- License: mit
- Created: 2023-11-07T23:34:18.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-01T15:09:25.000Z (about 1 year ago)
- Last Synced: 2024-12-01T16:36:48.681Z (about 1 month ago)
- Language: Rust
- Homepage: https://docs.rs/dodgems
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dodgems - A simple bump allocator library
This crate provides a fast, single-threaded bump allocator for use in performance
sensitive contexts.**⚠️ It is not a general purpose allocator: you need to have another
(supposedly slower) allocator to back it up.** By default, it is the global allocator.It can be used for quick and dirty allocation in a loop, where you know memory
can be reclaimed all at once at the end.# Example
```rust
#![feature(allocator_api)]
use dodgems::BumpCar;let mut bumpcar = BumpCar::new(1024).unwrap(); // 1kB capacity
for i in 0..100 {
// allocate with the allocator api
let mut v = Vec::new_in(&bumpcar);
v.push(42);
// small fast allocations in hot loopdrop(v);
// reset the capacity once every allocation has been dropped
bumpcar.reset();
}drop(bumpcar)
```Until the `allocator_api` is stable, this crate requires nightly.