67 releases (36 breaking)

new 0.36.0 Nov 9, 2024
0.34.0 Oct 26, 2024
0.22.1 Jul 28, 2024
0.11.0 Mar 30, 2024
0.0.1 Mar 30, 2023

#1158 in Programming languages

Download history 61547/week @ 2024-07-20 69245/week @ 2024-07-27 59100/week @ 2024-08-03 47594/week @ 2024-08-10 47824/week @ 2024-08-17 44840/week @ 2024-08-24 38523/week @ 2024-08-31 36441/week @ 2024-09-07 40384/week @ 2024-09-14 50219/week @ 2024-09-21 58231/week @ 2024-09-28 47222/week @ 2024-10-05 41100/week @ 2024-10-12 18015/week @ 2024-10-19 15068/week @ 2024-10-26 14598/week @ 2024-11-02

92,556 downloads per month
Used in 28 crates (19 directly)

MIT license

29KB
482 lines

⚓ Oxc Memory Allocator

Oxc uses a bump-based memory arena for faster AST allocations. This crate contains an Allocator for creating such arenas, as well as ports of memory management data types from std adapted to use this arena.

No Drops

Objects allocated into oxc memory arenas are never Dropped, making it relatively easy to leak memory if you're not careful. Memory is released in bulk when the allocator is dropped.

Examples

use oxc_allocator::{Allocator, Box};

struct Foo {
    pub a: i32
}
impl std::ops::Drop for Foo {
    fn drop(&mut self) {
        // Arena boxes are never dropped.
        unreachable!();
    }
}

let allocator = Allocator::default();
let foo = Box::new_in(Foo { a: 0 }, &allocator);
drop(foo);

Consumers of the oxc umbrella crate pass Allocator references to other tools.

use oxc::{allocator::Allocator, parser::Parser, span::SourceType};

let allocator = Allocator::default()
let parsed = Parser::new(&allocator, "let x = 1;", SourceType::default());
assert!(parsed.errors.is_empty());

Dependencies

~410–660KB