带有副作用的界面失败, 与“ malllctl* ()” 读/ wriite 处理没有直接关联
原标题:An interface with side effects failed in some way not directly related to `mallctl*()` read/write processing
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.
相关问题
Window still shows elements that are not being drawn anymore. The window is being cleared properly
I have some code setup with Windows GDI to create a transparent window and then draw a red transparent box in the upper left of the window. After a while, it moves the box a bit to the left and makes ...
Why does Rust ops::add want me to implement `add` with a move?
I m new to rust and going through the Google course for exercises as I go through "the book", I m on one of the exercises and I am needing to implement the + operator. So I go to the docs ...
How do I unescaped, string that has been escaped multiple times in Rust?
I have spent close to an hour on this already, so this is a true case of hitting a wall.
For reasons beyond my control, an internal service I am using hands me a JSON that is in this form
let ...
Rust compiler does not unify types that both `impl Future<Output=()>` in branches of `if let` expression
While trying to create a Future conditionally, for later use with select_biased!:
let mut heartbeat_timer = if let ServerState::Leader(_, _, _) = server_state {
// if we re ...
rust macro: combine params with literal string as function name error
I create a macro in rust:
macro_rules! generate_i64_get_inc{
($($field_name:ident),*) => {
$(
pub(super) fn get_$field_name(&self) -> i64 {
self. $...
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 ...
How to apply a function to multiple columns of a polars DataFrame in Rust
I d like to apply a user-define function which takes a few inputs (corresponding some columns in a polars DataFrame) to some columns of a polars DataFrame in Rust. The pattern that I m using is as ...
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 ...