70 releases (39 breaking)

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

#853 in Programming languages

Download history 46470/week @ 2024-08-16 46510/week @ 2024-08-23 39582/week @ 2024-08-30 36692/week @ 2024-09-06 39619/week @ 2024-09-13 49696/week @ 2024-09-20 56538/week @ 2024-09-27 53050/week @ 2024-10-04 41897/week @ 2024-10-11 18166/week @ 2024-10-18 15525/week @ 2024-10-25 14720/week @ 2024-11-01 16262/week @ 2024-11-08 17361/week @ 2024-11-15 13470/week @ 2024-11-22 14169/week @ 2024-11-29

64,038 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–660KB