Expand description
§⚓ 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());Structs§
- Memory address of an AST node in arena.
- A bump-allocated memory arena based on bumpalo.
- A
BoxwithoutDrop, which stores its data in the arena allocator. - A UTF-8 encoded, growable string.
- A
VecwithoutDrop, which stores its data in the arena allocator.
Traits§
- A trait to explicitly clone an object into an arena allocator.
- Trait for getting the memory address of an AST node.