These recipes favor modern HotSpot ergonomics: set the few flags that express a real requirement, observe with GC logs or JFR, and tune from evidence.
Default Production Service
Baseline heap sizing and GC logging for normal server processes on a current JDK.
Container or Kubernetes Service
Size heap from cgroup limits and inspect what the JVM detects inside the container.
Low-Latency API
Use ZGC when short pauses matter more than squeezing out every last point of throughput.
Throughput-Heavy Batch Job
Favor total completion time for ETL, indexing, reporting, and compiler-style workloads.
Predictable G1 Pauses
Stay with G1 and give the collector an explicit pause-time target to optimize toward.
Memory-Constrained Service
Reduce unused heap slack when process footprint matters more than peak throughput.
Compact Object Headers
Reduce per-object heap overhead for object-dense Java 25 workloads.
Class Data Sharing
Improve startup and memory footprint by reusing archived class metadata.
Many Duplicate Strings
Reduce heap pressure in workloads with repeated identifiers, JSON fields, and log values.
Crash and OOM Forensics
Collect heap dumps and JVM fatal-error files when production failures happen.
Continuous Profiling with JFR
Start a bounded Java Flight Recorder recording with low operational friction.
Native Memory Investigation
Explain RSS beyond Java heap: metaspace, thread stacks, direct buffers, and JVM internals.
Better Linux Profiling Stacks
Improve frame-pointer based stack traces for perf, async-profiler, and eBPF tooling.
Virtual Threads and Structured Concurrency
Scale blocking I/O with virtual threads and keep related subtasks bounded by a scope.
Stable Runtime Defaults
Pin encoding, timezone, and locale so logs and data pipelines behave consistently.
Module Access Workaround
Use explicit module opens as a temporary bridge for reflective legacy libraries.
TLS and Module Security
Configure truststores, keystores, TLS policy, and narrow module-access exceptions.
Print JVM Ergonomics
Show selected heap, GC, and VM settings at startup for support and diagnostics.