Startup and footprint evaluation
What you will learn
Evaluate startup, memory, throughput and build cost separately. A single short process launch does not prove service readiness or steady-state capacity. Compare matched application behavior under the same workload and collect raw measurements with explicit units.
- Design a fair JVM versus native comparison.
- Distinguish file size, heap, RSS and PSS.
- Interpret median and break-even calculations without generalizing.
Plain Java examples: save as Main.java in a fresh directory, then run javac --release 21 Main.java and java Main. Standalone Java 21 functional examples. GraalVM 25, Spring AOT and HotSpot 25 AOT cache recipes are source-reviewed, not executed. Companion AppCDS evidence is separate.
Median of a small fictional launch sample
public class Main { static long median(long[] samples) { if(samples.length==0 || samples.length%2==0) throw new IllegalArgumentException("odd nonempty sample required"); long[] copy=samples.clone(); java.util.Arrays.sort(copy); return copy[copy.length/2]; } public static void main(String[] args) { System.out.println(median(new long[]{80,100,90,120,95})); }}Expected output:
95Illustrative milliseconds, not measured values. Sort a copy; this helper handles odd sample counts only.
Measure actual startup and footprint
Measure process launch to a defined ready signal (or exit for a CLI). Use fresh processes, alternate order, preserve all trials, and describe host load and cache state. RSS includes shared pages per process; PSS apportions shared pages; heap is only one component. Record artifact bytes and build duration separately. Java 21 AppCDS may reduce preparation work; Java 25 AOT caching is a separate JVM feature. Native startup gains or sustained throughput trade-offs must be measured, never assumed.
AppCDS and AOT cache recipes
In the companion directory build the JAR, then java -XX:ArchiveClassesAtExit=app.jsa -jar catalog.jar. Run java -Xshare:on -XX:SharedArchiveFile=app.jsa -jar catalog.jar to require the archive, with matching JVM/classpath. Java 25 recipe (unexecuted): java -XX:AOTMode=record -XX:AOTConfiguration=app.aotconf -jar catalog.jar, then java -XX:AOTMode=create -XX:AOTConfiguration=app.aotconf -XX:AOTCache=app.aot -jar catalog.jar, then java -XX:AOTMode=on -XX:AOTCache=app.aot -jar catalog.jar. Train with representative synthetic data and do not distribute caches containing secrets. Check exact JDK flags and rebuild after dependency/JDK changes.
Calculate fictional storage overhead
public class Main {
public static void main(String[] args) { System.out.println(Math.addExact(2_000_000L, 8_000_000L)); }}Expected output:
10000000JAR plus archive bytes; runtime image and filesystem overhead are excluded.
Compute a hypothetical build-cost break-even
public class Main { static long breakEven(long buildMillis,long savedPerLaunch) { if(buildMillis<0 || savedPerLaunch<=0) throw new IllegalArgumentException(); return Math.ceilDiv(buildMillis,savedPerLaunch); } public static void main(String[] args) { System.out.println(breakEven(30000,100)); }}Expected output:
300A simplified time-only model using fictional inputs; not a deployment decision.
Common mistakes
Do not compare warm JVM throughput to cold native startup. Do not infer RSS from heap size or archive size, and do not discard slow trials. A native build cost is not a runtime latency measurement.
Practice
Use the break-even helper for 45 seconds extra build time and 150 milliseconds saved per launch. Print 300; reject zero savings.
Expected output:
300Compare with the manual review criteria.
Further reading: CDS · AOT cache · Native dynamic. Independent editorial review remains pending.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Startup and footprint evaluation — knowledge check
AOT and deployment reasoning.
What is RSS?
What is PSS?
What does -Xshare:on require?
How should launch trials be compared?
What proves native startup gains?