Skip to main content

Crate ax_alloc

Crate ax_alloc 

Source
Expand description

ArceOS global memory allocator.

It provides GlobalAllocator, which implements the trait core::alloc::GlobalAlloc. A static global variable of type GlobalAllocator is defined with the #[global_allocator] attribute, to be registered as the standard library’s default allocator.

Modules§

tracking
Tracking of memory usage, enabled with the tracking feature.

Structs§

GlobalAllocator
The global allocator used by ArceOS when TLSF is enabled.
GlobalPage
A RAII wrapper of contiguous 4K-sized pages.
Usages
Statistics of memory usages.

Enums§

AllocError
The error type used for allocation operations in ax-alloc.
UsageKind
Kinds of memory usage for tracking.

Traits§

AllocatorOps
Unified allocator operations provided by all ax-alloc backends.

Functions§

global_add_memory
Add the given memory region to the global allocator.
global_allocator
Returns the reference to the global allocator.
global_init
Initializes the global allocator with the given memory region.
init_percpu_slab
Initializes per-CPU allocator state.
register_page_reclaim_fn
Register a callback that the allocator will invoke when a page allocation cannot be satisfied.
try_page_reclaim
Try to reclaim physical pages by invoking the registered callback. Returns the number of pages actually freed.

Type Aliases§

AllocResult
A Result alias with AllocError as the error type.
DefaultByteAllocator
The default byte allocator for TLSF mode.
PageReclaimFn
A function that tries to reclaim physical pages (e.g. by evicting clean file-backed page cache pages). Returns the number of pages freed.