swc_malloc/
lib.rs

1//! This crate configures memory allocator.
2//!
3//! The swc crates related to the  node binding should depend on this crate.
4
5#[cfg(any(
6    not(any(
7        target_os = "linux",
8        target_family = "wasm",
9        target_env = "musl",
10        all(target_os = "linux", any(target_arch = "aarch64", target_arch = "arm"))
11    )),
12    all(
13        target_os = "linux",
14        not(any(
15            target_family = "wasm",
16            target_env = "musl",
17            all(target_os = "linux", any(target_arch = "aarch64", target_arch = "arm"))
18        ))
19    )
20))]
21#[global_allocator]
22static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
23
24// On linux aarch64, mimalloc fails to build.
25// So we use tikv-jemallocator instead.
26
27#[cfg(all(target_os = "linux", any(target_arch = "aarch64", target_arch = "arm")))]
28#[global_allocator]
29static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;