forked from pola-rs/polars
-
Notifications
You must be signed in to change notification settings - Fork 0
/
allocator.rs
49 lines (45 loc) · 1.33 KB
/
allocator.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#[cfg(all(
target_family = "unix",
not(feature = "default_allocator"),
not(feature = "use_mimalloc"),
))]
use jemallocator::Jemalloc;
#[cfg(all(
not(debug_assertions),
not(feature = "default_allocator"),
any(not(target_family = "unix"), feature = "use_mimalloc"),
))]
use mimalloc::MiMalloc;
#[cfg(all(
debug_assertions,
target_family = "unix",
not(feature = "default_allocator"),
not(feature = "use_mimalloc"),
))]
use crate::memory::TracemallocAllocator;
#[global_allocator]
#[cfg(all(
not(debug_assertions),
not(feature = "use_mimalloc"),
not(feature = "default_allocator"),
target_family = "unix",
))]
static ALLOC: Jemalloc = Jemalloc;
#[global_allocator]
#[cfg(all(
not(debug_assertions),
not(feature = "default_allocator"),
any(not(target_family = "unix"), feature = "use_mimalloc"),
))]
static ALLOC: MiMalloc = MiMalloc;
// On Windows tracemalloc does work. However, we build abi3 wheels, and the
// relevant C APIs are not part of the limited stable CPython API. As a result,
// linking breaks on Windows if we use tracemalloc C APIs. So we only use this
// on Unix for now.
#[global_allocator]
#[cfg(all(
debug_assertions,
not(feature = "default_allocator"),
target_family = "unix",
))]
static ALLOC: TracemallocAllocator<Jemalloc> = TracemallocAllocator::new(Jemalloc);