You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MALLOC_ARENA_MAX is set but never exported, so the JVM does not receive it #1433
After migrating our java apps in cf from the Ruby-based 4.x buildpack to 5.0.4 go rewrite, we observed a steadily growing number of memory consumed in comparison to the old buildpack.
We tried different things and the behaviour hinted at a missing setting of MALLOC_ARENA_MAX. We have added this manually in the manifest and it solved the issues for us. That was surprising, because the buildpack's own start command
already contains MALLOC_ARENA_MAX=2 — which is what led to the investigation and this issue.
Investigation
We compared the start commands and notice, that in the Ruby-based 4.x buildpack, the assignments are a prefix of the command, so they are available in the java process:
which returned nothing under 5.0.4 while the start command reported by cf curl "/v3/apps/$(cf app APP --guid)/processes" contains MALLOC_ARENA_MAX=2.
And vice versa, in the 4.77.0 it is present in the acutal JVM and the start commands.
Fix
I prepared a small fix here: #1434
Please note: I haven't fully understand why there is still the code path for shell script generation of memory_calculator.sh, but this path does the "right thing" already with exporting the value.
Suspected root cause
The memory_calculator.go ends the snippet with && MALLOC_ARENA_MAX=2 and finalize.go:268 appends " && " + containerCommand after it. Due to this, MALLOC_ARENA_MAX remains a plain shell variable and
is not exported for the java process.
Expected behavior
MALLOC_ARENA_MAX=2 is part of the environment of the JVM process.
Actual behavior
MALLOC_ARENA_MAX=2 appears in the start command, but is absent from the JVM
changed the title [-]MALLOC_ARENA_MAX is set but never exported, so the JVM does not receive it[/-][+]`MALLOC_ARENA_MAX` is set but never exported, so the JVM does not receive it[/+]on Sep 25, 2026
We will look into it as it might explain increase in memory usage reported by others as well. (Seems due to memory fragmentation as I understand it.) As the setting was present on the command line, it made this not obvious.
Activity
Export MALLOC_ARENA_MAX in the start command
[-]MALLOC_ARENA_MAX is set but never exported, so the JVM does not receive it[/-][+]`MALLOC_ARENA_MAX` is set but never exported, so the JVM does not receive it[/+]stokpop commentedon Sep 28, 2026
Thanks for reporting and the PR!
We will look into it as it might explain increase in memory usage reported by others as well. (Seems due to memory fragmentation as I understand it.) As the setting was present on the command line, it made this not obvious.
Export MALLOC_ARENA_MAX in the start command
stokpop commentedon Oct 2, 2026
BTW, for reference, I did some experiments to see the effect of this setting: https://github.com/stokpop/scramjet/tree/main/experiments/malloc-arena-max
chore: remove dead memory_calculator.sh script generation