{"record":{"id":"915978ea390dfd17","repo":"pola-rs/polars","slug":"invalid-value-for-polars-override-total-memory-s","errorCode":null,"errorMessage":"invalid value for POLARS_OVERRIDE_TOTAL_MEMORY: {s}","messagePattern":"invalid value for POLARS_OVERRIDE_TOTAL_MEMORY: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-utils/src/sys.rs","lineNumber":22,"sourceCode":"\n/// Return the total system memory in bytes.\npub fn total_memory() -> u64 {\n    return *TOTAL_MEMORY;\n\n    static TOTAL_MEMORY: LazyLock<u64> = LazyLock::new(|| {\n        let mut sys = System::new();\n\n        sys.refresh_memory_specifics(MemoryRefreshKind::nothing().with_ram());\n\n        let mut v: u64 = match sys.cgroup_limits() {\n            Some(limits) => limits.total_memory,\n            None => sys.total_memory(),\n        };\n\n        if let Ok(s) = std::env::var(\"POLARS_OVERRIDE_TOTAL_MEMORY\") {\n            v = s\n                .parse::<u64>()\n                .unwrap_or_else(|_| panic!(\"invalid value for POLARS_OVERRIDE_TOTAL_MEMORY: {s}\"))\n        }\n\n        if polars_config::config().verbose() {\n            let gib = (v as f64) / (1024.0 * 1024.0 * 1024.0);\n            eprintln!(\"total memory: {gib:.3} GiB ({v} bytes)\")\n        }\n\n        v\n    });\n}\n\n/// Startup system is expensive, so we do it once\npub struct MemInfo {\n    sys: Mutex<System>,\n}\n\nimpl MemInfo {\n    /// This call is quite expensive, cache the results.","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-utils/src/sys.rs#L4-L40","documentation":"total_memory() lets users override the detected system memory via the POLARS_OVERRIDE_TOTAL_MEMORY environment variable; the value must parse as u64 bytes, otherwise it panics naming the invalid string.","triggerScenarios":"Setting POLARS_OVERRIDE_TOTAL_MEMORY to a non-numeric value (e.g. '8g' or '8GB') or to a value too large for u64.","commonSituations":"Users copying docs/examples expecting unit suffixes ('16GB'), typos in the numeric string, or setting the variable in CI with an invalid placeholder value.","solutions":["Set POLARS_OVERRIDE_TOTAL_MEMORY to a plain integer number of bytes, e.g. 17179869184 for 16 GiB","Unset the variable to fall back to auto-detected system memory","Check the current value: echo $POLARS_OVERRIDE_TOTAL_MEMORY and fix or remove it"],"exampleFix":"// before\nPOLARS_OVERRIDE_TOTAL_MEMORY=16GB\n// after\nPOLARS_OVERRIDE_TOTAL_MEMORY=17179869184","handlingStrategy":"validation","validationCode":"import os\nv = os.environ.get(\"POLARS_OVERRIDE_TOTAL_MEMORY\")\nif v is not None:\n    assert v.isdigit() and int(v) < 2**64, f\"POLARS_OVERRIDE_TOTAL_MEMORY must be a u64 byte count, got {v!r}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set byte counts without unit suffixes (17179869184, not '16GB')","Document the env var's expected format in team runbooks/CI templates","Unset the variable when auto-detection is acceptable"],"tags":["rust","environment-variable","config","memory"],"backgroundTag":"invalid-env-var-value","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}