77 releases (45 breaking)

new 0.45.0 Jan 11, 2025
0.44.0 Dec 25, 2024
0.43.0 Dec 21, 2024
0.38.0 Nov 26, 2024
0.0.1 Mar 30, 2023

#917 in Programming languages

Download history 51065/week @ 2024-09-22 58139/week @ 2024-09-29 46335/week @ 2024-10-06 40540/week @ 2024-10-13 18206/week @ 2024-10-20 14639/week @ 2024-10-27 15150/week @ 2024-11-03 16600/week @ 2024-11-10 17166/week @ 2024-11-17 11458/week @ 2024-11-24 16308/week @ 2024-12-01 15386/week @ 2024-12-08 14659/week @ 2024-12-15 7145/week @ 2024-12-22 10072/week @ 2024-12-29 15711/week @ 2025-01-05

49,040 downloads per month
Used in 32 crates (20 directly)

MIT license

34KB
574 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

~510–750KB
~11K SLoC