foundry_cli/utils/allocator.rs
1//! Abstract global allocator implementation.
2
3// If jemalloc feature is enabled on Unix systems, use jemalloc as the global allocator.
4// Otherwise, explicitly use the system allocator.
5cfg_if::cfg_if! {
6 if #[cfg(all(feature = "jemalloc", unix))] {
7 type AllocatorInner = tikv_jemallocator::Jemalloc;
8 } else {
9 type AllocatorInner = std::alloc::System;
10 }
11}
12
13pub type Allocator = AllocatorInner;
14
15/// Creates a new [allocator][Allocator].
16pub const fn new_allocator() -> Allocator {
17 AllocatorInner {}
18}