Files
Claude e83c9949d8 Add jdk27-memory: compact object headers and G1-everywhere on a Spring Boot service
Spring Boot 4.1.1 catalog service measured on JDK 25, 26 and 27: live heap 320 MB to 273 MB with compact headers, per-class bytes per instance, container-sizing sweeps with real cgroup limits, 1-CPU Serial vs G1 with Native Memory Tracking, removed flags (MaxRAM, UseCompressedClassPointers), and a kernel OOM-kill check. Outputs in jdk27-memory/output.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TF9JWFvJSNm6HVzswzZU5a
2026-09-24 15:09:55 +00:00

29 lines
1.8 KiB
Bash

#!/usr/bin/env bash
# What does "killed" mean in the container sweep? Runs the edge case (JDK 27, compact headers off, 400 MB
# container, heap 75%) a few times and reads the cgroup's own counters and the kernel log afterwards, so the
# claim "the kernel's memory controller killed it" rests on the kernel's say-so and not on an exit code.
source "$(dirname "$0")/lib.sh"
KILLED=()
echo "# JDK 27, -XX:-UseCompactObjectHeaders -XX:MaxRAMPercentage=75, container limit 400 MB, 2 CPUs; 2,000,000 products"
for attempt in 1 2 3 4; do
cg="oomchk$attempt"
cg_create "$cg" $((400*1024*1024)) 2
port=$((30000 + RANDOM % 5000))
bash -c "$CG_JOIN" _ "$cg" "$JDK27/bin/java" -XX:MaxRAMPercentage=75 -XX:-UseCompactObjectHeaders -jar "$JAR" --server.port=$port >/dev/null 2>&1 &
pid=$!
for _ in $(seq 1 120); do curl -sf localhost:$port/ping >/dev/null 2>&1 && break; sleep 0.25; done
resp=$(curl -s --max-time 25 -o /dev/null -w '%{http_code}' "localhost:$port/load?n=2000000")
sleep 1
if kill -0 $pid 2>/dev/null; then state="process still alive"; else wait $pid 2>/dev/null; state="process gone, exit $?"; KILLED+=("$pid"); fi
echo "== attempt $attempt: /load answered HTTP $resp; $state"
echo " memory.failcnt=$(cat $CGROOT/memory/$cg/memory.failcnt) memory.max_usage=$(( $(cat $CGROOT/memory/$cg/memory.max_usage_in_bytes) / 1048576 ))MB limit=$(( $(cat $CGROOT/memory/$cg/memory.limit_in_bytes) / 1048576 ))MB $(grep '^oom_kill ' $CGROOT/memory/$cg/memory.oom_control)"
kill $pid 2>/dev/null; wait $pid 2>/dev/null
cg_remove "$cg"
echo
done
echo "== the kernel log (dmesg): what it says about the processes that disappeared above"
for p in "${KILLED[@]:-}"; do
[ -n "$p" ] && dmesg 2>/dev/null | grep "Memory cgroup out of memory: Killed process $p " | sed 's/^\[[ 0-9.]*\] //'
done
exit 0