When I tried to dump rust in macOS 13.4 with M1 chip like this:
use jemalloc_ctl::{AsName, Access};
use std::collections::HashMap;
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
const PROF_ACTIVE: &'static [u8] = b"prof.active";
const PROF_DUMP: &'static [u8] = b"prof.dump";
const PROFILE_OUTPUT: &'static [u8] = b"profile.out";
fn set_prof_active(active: bool) {
let name = PROF_ACTIVE.name();
name.write(active).expect("Should succeed to set prof");
}
fn dump_profile() {
let name = PROF_DUMP.name();
name.write(PROFILE_OUTPUT).expect("Should succeed to dump profile")
}
fn main() {
set_prof_active(true);
let mut buffers: Vec<HashMap<i32, i32>> = Vec::new();
for _ in 0..100 {
buffers.push(HashMap::with_capacity(1024));
}
set_prof_active(false);
dump_profile();
}
The output shows the following error:
thread 'main' panicked at src/main.rs:18:32:
Should succeed to dump profile: An interface with side effects failed in some way not directly related to `mallctl*()` read/write processing.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Does jemolloc not support macOS? Am I missing something? This is the Cargo.toml
:
[package]
name = "rust-learn"
version = "0.1.0"
edition = "2018"
[dependencies]
jemallocator = "0.3.2"
jemalloc-ctl = "0.3.2"
[dependencies.jemalloc-sys]
version = "0.3.2"
features = ["stats", "profiling", "unprefixed_malloc_on_supported_platforms"]
[profile.release]
debug = true
This is the rust version:
➜ rust-learn git:(rustflags) ✗ rustup -V
rustup 1.27.1 (54dd3d00f 2024-04-24)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.79.0 (129f3b996 2024-06-10)