Skip to content

Commit 94a3abf

Browse files
committed
use jemallocator override_allocator_on_supported_platforms feature
1 parent 51cd261 commit 94a3abf

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,23 @@ clap = { version = "4.5.49", default-features = true, features = [
4444
"derive",
4545
"env",
4646
] }
47-
tokio = { version = "1.48.0", default-features = false, features = [
48-
"macros",
49-
"rt-multi-thread",
50-
] }
51-
52-
53-
[dev-dependencies.tikv-jemallocator]
54-
features = [
47+
tikv-jemalloc-sys = { version = "0.6.1", default-features = false }
48+
tikv-jemallocator = { version = "0.6.1", features = [
5549
# https://github.com/tikv/jemallocator/blob/master/jemalloc-sys/README.md#features
5650
# https://github.com/jemalloc/jemalloc/blob/dev/TUNING.md
5751
"background_threads_runtime_support",
5852
"background_threads",
5953
"stats",
6054
"unprefixed_malloc_on_supported_platforms",
6155
"profiling",
62-
]
63-
version = "0.6.1"
56+
# override the system allocator even outside Rust code.
57+
# https://github.com/tikv/jemallocator/blob/0.6.1/jemalloc-sys/README.md?plain=1#L91.
58+
"override_allocator_on_supported_platforms",
59+
] }
60+
tokio = { version = "1.48.0", default-features = false, features = [
61+
"macros",
62+
"rt-multi-thread",
63+
] }
6464

6565
[features]
6666
default = ["pprof"]

examples/server.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ use tokio::{
1212
#[global_allocator]
1313
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
1414

15+
// Override the system allocator even outside Rust code.
16+
// See https://github.com/tikv/jemallocator/blob/0.6.1/jemalloc-sys/README.md?plain=1#L91.
17+
#[cfg(not(target_env = "msvc"))]
18+
use tikv_jemalloc_sys as _;
19+
1520
/// Global jemalloc allocator config for memory profiling.
1621
/// Define this at the root of your app.
1722
#[allow(non_upper_case_globals)]

0 commit comments

Comments
 (0)