1
#[cfg(feature = "merc_metrics")]
2
use log::info;
3

            
4
#[cfg(feature = "merc_metrics")]
5
#[global_allocator]
6
static GLOBAL_ALLOCATOR: crate::AllocCounter = crate::AllocCounter::new();
7

            
8
#[cfg(not(target_env = "msvc"))]
9
#[cfg(not(feature = "merc_metrics"))]
10
#[cfg(feature = "merc_jemalloc")]
11
#[global_allocator]
12
static GLOBAL_ALLOCATOR: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
13

            
14
#[cfg(not(feature = "merc_metrics"))]
15
#[cfg(feature = "merc_mimalloc")]
16
#[global_allocator]
17
static GLOBAL_ALLOCATOR: mimalloc::MiMalloc = mimalloc::MiMalloc;
18

            
19
/// Prints information from the [AllocCounter].
20
#[cfg(feature = "merc_metrics")]
21
pub fn print_allocator_metrics() {
22
    info!("{}", GLOBAL_ALLOCATOR.get_metrics());
23
}
24

            
25
#[cfg(not(feature = "merc_metrics"))]
26
pub fn print_allocator_metrics() {}