English 中文(简体)
带有副作用的界面失败, 与“ malllctl* ()” 读/ wriite 处理没有直接关联
原标题:An interface with side effects failed in some way not directly related to `mallctl*()` read/write processing
  • 时间:2024-07-23 15:10:08
  •  标签:
  • rust
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> = 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)
问题回答
MALLOC_CONF=prof:true need to be set when building jemalloc. Before building the project, set it like the following: export JEMALLOC_SYS_WITH_MALLOC_CONF="prof:true" This will instruct jemalloc-sys to pass it to jemalloc. If this still does not work, run cargo clean and rebuild the project.




相关问题
Creating an alias for a variable

I have the following code in Rust (which will not compile but illustrates what I am after). For readability purposes, I would like to refer the same string with two different names so that the name of ...

Rust Visual Studio Code code completion not working

I m trying to learn Rust and installed the Rust extension for VSCode. But I m not seeing auto-completions for any syntax. I d like to call .trim() on String but I get no completion for it. I read that ...

热门标签