72 releases (40 breaking)

new 0.40.1 Dec 10, 2024
0.39.0 Dec 4, 2024
0.38.0 Nov 26, 2024
0.22.1 Jul 28, 2024
0.0.1 Mar 30, 2023

#787 in Programming languages

Download history 45648/week @ 2024-08-22 38736/week @ 2024-08-29 39775/week @ 2024-09-05 39232/week @ 2024-09-12 46815/week @ 2024-09-19 55580/week @ 2024-09-26 55709/week @ 2024-10-03 41837/week @ 2024-10-10 22716/week @ 2024-10-17 16128/week @ 2024-10-24 14684/week @ 2024-10-31 15995/week @ 2024-11-07 16795/week @ 2024-11-14 15502/week @ 2024-11-21 12223/week @ 2024-11-28 16471/week @ 2024-12-05

64,052 downloads per month
Used in 28 crates (18 directly)

MIT license

30KB
499 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

~415–670KB