mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 07:09:59 -07:00
22 lines
521 B
Rust
22 lines
521 B
Rust
//! Global allocator and memory utilities for brk.
|
|
//!
|
|
//! This crate sets mimalloc as the global allocator and provides
|
|
//! utilities for monitoring and managing memory.
|
|
|
|
use mimalloc::MiMalloc as Allocator;
|
|
|
|
#[global_allocator]
|
|
static GLOBAL: Allocator = Allocator;
|
|
|
|
/// Mimalloc allocator utilities
|
|
pub struct Mimalloc;
|
|
|
|
impl Mimalloc {
|
|
/// Eagerly free memory back to OS.
|
|
/// Only call at natural pause points.
|
|
#[inline]
|
|
pub fn collect() {
|
|
unsafe { libmimalloc_sys::mi_collect(true) }
|
|
}
|
|
}
|