{"record":{"id":"eca174f089047e35","repo":"influxdata/influxdb","slug":"heap-profiling-is-disabled-restart-with-malloc-conf-env-prof","errorCode":null,"errorMessage":"heap profiling is disabled; restart with {MALLOC_CONF_ENV}=prof:true to enable","messagePattern":"heap profiling is disabled; restart with (.+?)=prof:true to enable","errorType":"error_code","errorClass":"HeapDumpError::ProfilingDisabled","httpStatus":null,"severity":"error","filePath":"core/jemalloc_stats/src/lib.rs","lineNumber":94,"sourceCode":"/// in a user-facing message differs by build target.\npub const MALLOC_CONF_ENV: &str = if cfg!(any(\n    target_os = \"macos\",\n    target_os = \"ios\",\n    target_os = \"android\",\n    target_os = \"dragonfly\",\n    target_env = \"musl\",\n)) {\n    \"_RJEM_MALLOC_CONF\"\n} else {\n    \"MALLOC_CONF\"\n};\n\n/// Errors returned by [`dump_heap_profile`].\n#[derive(Debug, thiserror::Error)]\npub enum HeapDumpError {\n    #[error(\"tempfile path was not valid C string (non-utf8 or interior NUL)\")]\n    BadTempPath,\n    #[error(\"heap profiling is disabled; restart with {MALLOC_CONF_ENV}=prof:true to enable\")]\n    ProfilingDisabled,\n    #[error(\"jemalloc prof.dump failed: {0}\")]\n    Jemalloc(#[from] tikv_jemalloc_ctl::Error),\n    #[error(\"tempfile i/o: {0}\")]\n    Io(#[from] std::io::Error),\n    #[error(\"blocking task join: {0}\")]\n    Join(#[from] tokio::task::JoinError),\n}\n\n/// Trigger a jemalloc heap profile dump and return a streaming reader for\n/// the resulting `heap_v2` bytes.\n///\n/// Requires jemalloc built with `--enable-prof` (i.e. `tikv-jemallocator`\n/// `profiling` feature) AND the binary started with `prof:true` in the\n/// platform-appropriate `MALLOC_CONF` env var (or via a baked-in\n/// `malloc_conf` static — see [`DEFAULT_MALLOC_CONF`]). When profiling is\n/// disabled at startup this returns [`HeapDumpError::ProfilingDisabled`].\n///","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/jemalloc_stats/src/lib.rs#L76-L112","documentation":"HeapDumpError::ProfilingDisabled is returned by dump_heap_profile when jemalloc's heap profiling feature (prof) is not active in the running process. The crate requires the process to have been started with the MALLOC_CONF environment containing prof:true; without it jemalloc cannot produce heap_v2 profile dumps. This is a configuration/runtime-startup condition, not a runtime fault.","triggerScenarios":"Calling dump_heap_profile() (or hitting the pprof heap endpoint) in a process launched without MALLOC_CONF=prof:true — for example a service started with default env or a MALLOC_CONF that lacks the prof option.","commonSituations":"Deploying the binary without the jemalloc profiling env var; enabling the pprof HTTP endpoint but forgetting the restart flag; MALLOC_CONF overwritten by another profiling config (e.g. only abort_conf or background_thread set).","solutions":["Restart the process with MALLOC_CONF=prof:true (combined with any other needed options) as the error message instructs","Verify with `MALLOC_CONF=print:true` or by checking the endpoint that profiling is enabled after restart","If profiling is too costly in prod, keep it enabled only in staging/debug deployments"],"exampleFix":"// before\n./myapp\n// after\nMALLOC_CONF=prof:true ./myapp","handlingStrategy":"validation","validationCode":"fn profiling_enabled() -> bool {\n    std::env::var(\"MALLOC_CONF\").map(|v| v.split(',').any(|o| o == \"prof:true\")).unwrap_or(false)\n}\nif !profiling_enabled() { return Err(\"start with MALLOC_CONF=prof:true\"); }","typeGuard":null,"tryCatchPattern":"match dump_heap_profile().await {\n    Err(HeapDumpError::ProfilingDisabled) => HttpResponse::new(StatusCode::PRECONDITION_FAILED, \"enable MALLOC_CONF=prof:true\"),\n    other => other?,\n}","preventionTips":["Set MALLOC_CONF=prof:true in the service's deployment manifest","Document the env requirement next to the pprof endpoint","Check profiling is active at startup and log a warning if not"],"tags":["rust","jemalloc","heap-profiling","configuration","env-var"],"backgroundTag":"feature-not-enabled","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}