-
Notifications
You must be signed in to change notification settings - Fork 6
Memory Calculator Ignores BPL_JVM_HEAD_ROOM Environment Variable - Uses BPL_JVM_HEADROOM Instead #600
Description
The Paketo Azul Zulu buildpack recognizes during build time (visible in logs) but the memory calculator ignores it at runtime, always showing Headroom: 0%. The workaround is to use instead, suggesting the runtime memory calculator expects BPL_JVM_HEADROOM (without the underscore before "ROOM"). This inconsistency between build-time configuration and runtime behavior prevents proper JVM memory headroom allocation. BPL_JVM_HEAD_ROOM``BPE_OVERRIDE_BPL_JVM_HEADROOM
Expected Behavior
Memory Calculator Ignores BPL_JVM_HEAD_ROOM Environment Variable - Uses BPL_JVM_HEADROOM Instead
Current Behavior
The build logs correctly show that BPL_JVM_HEAD_ROOM=12 is recognized during the build phase:
$BPL_JVM_HEAD_ROOM 12 the headroom in memory calculation
However, at runtime, the memory calculator completely ignores this setting and shows:
Calculating JVM memory based on 10144180K available memory
Calculated JVM Memory Configuration: -XX:MaxDirectMemorySize=10M -Xmx9271873K -XX:MaxMetaspaceSize=360306K -XX:ReservedCodeCacheSize=240M -Xss1M (Total Memory: 10144180K, Thread Count: 250, Loaded Class Count: 61199, Headroom: 0%)
The memory calculator allocates nearly 100% of available memory instead of reserving the configured 12% headroom.
Possible Solution
The Azul Zulu buildpack should handle the environment variable name inconsistency between user configuration and the memory calculator. Suggested approaches:
Option 1: Transform/Map Variables (Recommended) The buildpack should internally map to BPL_JVM_HEADROOM before invoking the memory calculator: BPL_JVM_HEAD_ROOM
Option 2: Support Both Variable Names Update the memory calculator (or buildpack's memory calculation logic) to check for both variable names:
- (documented/current)
BPL_JVM_HEAD_ROOM BPL_JVM_HEADROOM(what actually works)
Steps to Reproduce
Environment:
- Buildpack:
paketobuildpacks/azul-zulu:11.2.3 - Java Version: 24 (JRE)
- Builder:
paketobuildpacks/builder-jammy-base:latest
Steps:
- Configure Spring Boot
bootBuildImagetask with environment variableBPL_JVM_HEAD_ROOM: "12" - Build container image using
./gradlew bootBuildImage - Observe build logs show the variable is recognized
- Run container with sufficient memory allocation
- Check container startup logs for memory calculator output
- Notice
Headroom: 0%instead of expectedHeadroom: 12%
Workaround: Adding BPE_OVERRIDE_BPL_JVM_HEADROOM: "12" (note: no underscore before "ROOM") to the environment configuration correctly applies the headroom setting.
Motivations
This issue prevents proper JVM memory management in production environments. Without headroom, applications are more susceptible to OutOfMemoryErrors during memory pressure situations. The discrepancy between documented configuration () and actual runtime behavior creates confusion and requires workarounds that aren't obvious to users. BPL_JVM_HEAD_ROOM
The impact is particularly significant for:
- Production deployments where memory management is critical
- Applications with high memory usage that need buffer space
- Teams following Paketo documentation who expect the documented variables to work correctly