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    all(target_os = "linux", target_arch = "aarch64", target_env = "gnu")
21))]
22#[global_allocator]
23static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
24
25// On linux aarch64, mimalloc fails to build.
26// So we use tikv-jemallocator instead.
27
28#[cfg(all(target_os = "linux", target_env = "gnu", target_arch = "arm"))]
29#[global_allocator]
30static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;