#!/usr/bin/env bash # Bytes per instance of the classes that dominate the heap, from GC.class_histogram of the runs made by # footprint.sh (kept in target/hist). The point: which classes shrink, and which do not. source "$(dirname "$0")/lib.sh" H="$MOD/target/hist" echo "== bytes per instance (= #bytes / #instances) from jcmd GC.class_histogram after loading 2,000,000 products" printf '%-40s %14s %14s %14s\n' "class" "JDK 26 default" "JDK 27 default" "JDK 27 opt-out" for cls in 'com.ankurm.memory.Product' 'java.util.HashMap$Node' 'java.lang.Long' 'java.lang.String' '[B'; do printf '%-40s' "$cls" for cfg in jdk26-default jdk27-default jdk27-optout; do awk -v c="$cls" '$4==c {printf " %14.1f", $3/$2; found=1} END{if(!found) printf " %14s","?"}' "$H/$cfg.txt" done echo done echo echo "== total bytes of those five classes" for cfg in jdk26-default jdk27-default jdk27-optout; do awk -v cfg="$cfg" '$4=="com.ankurm.memory.Product"||$4=="java.util.HashMap$Node"||$4=="java.lang.Long"||$4=="java.lang.String"||$4=="[B" {s+=$3} END{printf "%-16s %d bytes (%.1f MB)\n", cfg, s, s/1048576}' "$H/$cfg.txt" done