{"record":{"id":"3f855b70fc18861d","repo":"elastic/elasticsearch","slug":"unable-to-parse-number-of-bytes-from-totalmemor","errorCode":null,"errorMessage":"Unable to parse number of bytes from [${totalMemoryBytesOption}]","messagePattern":"Unable to parse number of bytes from \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"distribution/tools/server-cli/src/main/java/org/elasticsearch/server/cli/OverridableSystemMemoryInfo.java","lineNumber":43,"sourceCode":"    public OverridableSystemMemoryInfo(final List<String> userDefinedJvmOptions, SystemMemoryInfo fallbackSystemMemoryInfo) {\n        this.userDefinedJvmOptions = Objects.requireNonNull(userDefinedJvmOptions);\n        this.fallbackSystemMemoryInfo = Objects.requireNonNull(fallbackSystemMemoryInfo);\n    }\n\n    @Override\n    public long availableSystemMemory() {\n\n        return userDefinedJvmOptions.stream()\n            .filter(option -> option.startsWith(\"-Des.total_memory_bytes=\"))\n            .map(totalMemoryBytesOption -> {\n                try {\n                    long bytes = Long.parseLong(totalMemoryBytesOption.split(\"=\", 2)[1]);\n                    if (bytes < 0) {\n                        throw new IllegalArgumentException(\"Negative memory size specified in [\" + totalMemoryBytesOption + \"]\");\n                    }\n                    return bytes;\n                } catch (NumberFormatException e) {\n                    throw new IllegalArgumentException(\"Unable to parse number of bytes from [\" + totalMemoryBytesOption + \"]\", e);\n                }\n            })\n            .reduce((previous, current) -> current) // this is effectively findLast(), so that ES_JAVA_OPTS overrides jvm.options\n            .orElse(fallbackSystemMemoryInfo.availableSystemMemory());\n    }\n}\n","sourceCodeStart":25,"sourceCodeEnd":50,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/distribution/tools/server-cli/src/main/java/org/elasticsearch/server/cli/OverridableSystemMemoryInfo.java#L25-L50","documentation":"Thrown by OverridableSystemMemoryInfo.availableSystemMemory() when the value after -Des.total_memory_bytes= cannot be parsed as a long (NumberFormatException). The override expects a plain decimal byte count.","triggerScenarios":"Setting -Des.total_memory_bytes to a non-numeric string, a value with units (e.g. '8g'), or with stray characters.","commonSituations":"Passing '8g' or '8192m' instead of raw bytes; trailing whitespace; copy-paste from a doc that used units; locale-specific number formatting (comma separators).","solutions":["Provide the value as a plain integer number of bytes: -Des.total_memory_bytes=8589934592.","Do not append unit suffixes (g/m/k) — the parser uses Long.parseLong.","Strip any whitespace/quotes around the value."],"exampleFix":"# before\nES_JAVA_OPTS=\"-Des.total_memory_bytes=8g\"\n\n# after (raw bytes)\nES_JAVA_OPTS=\"-Des.total_memory_bytes=8589934592\"","handlingStrategy":"validation","validationCode":"for (String o : userDefinedJvmOptions) {\n    if (o.startsWith(\"-Des.total_memory_bytes=\")) {\n        String raw = o.split(\"=\", 2)[1];\n        if (!raw.matches(\"\\\\d+\")) {\n            throw new IllegalArgumentException(\"total_memory_bytes must be a plain decimal: \" + o);\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass raw bytes only — no 'g'/'m' suffixes.","Strip whitespace and quotes around the value.","Document the unit (bytes) next to any override."],"tags":["jvm","memory","heap","config","parsing"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}