brk_alloc/lib.rs
1//! Global allocator and memory utilities for brk.
2//!
3//! This crate sets mimalloc as the global allocator and provides
4//! utilities for monitoring and managing memory.
5
6use mimalloc::MiMalloc as Allocator;
7
8#[global_allocator]
9static GLOBAL: Allocator = Allocator;
10
11/// Mimalloc allocator utilities
12pub struct Mimalloc;
13
14impl Mimalloc {
15 /// Eagerly free memory back to OS.
16 /// Only call at natural pause points.
17 #[inline]
18 pub fn collect() {
19 unsafe { libmimalloc_sys::mi_collect(true) }
20 }
21}