Skip to content

API

Sizing as code: everything the calculator computes, as JSON. No authentication, no state — the same model, the same numbers.

Endpoint

GET /api/size

Parameters

All optional; the defaults mirror the calculator exactly. The parameter names are the same ones the calculator keeps in its URL — a shared sizing link and an API call are interchangeable.

ParamTypeDefaultSemantics
v21 | 2525Java version the model targets.
gcG1 | ZGC | Serial | ParallelG1Garbage collector — changes the native GC-structures estimate.
modeheap | containerheapheap: you provide the heap, the API derives the limit. container: you provide the limit, the API solves the largest heap that fits.
heapnumber (MiB)384Desired heap (-Xmx). Used in heap mode only.
limitnumber (Mi)1024Container memory limit. Used in container mode only.
threadsnumber85Expected platform threads (stacks are counted as reserved upper bound: threads × xss).
classesnumber30000Expected loaded classes — drives the metaspace and internals estimates.
xssnumber (MiB)1Stack size per thread (-Xss).
ccnumber (MiB)64ReservedCodeCacheSize.
dmnumber (MiB)10MaxDirectMemorySize.
hrnumber (%)15Headroom applied on top of the JVM subtotal.

Response

200 for the reference case (/api/size?heap=384 with defaults):

{
  "inputs": {
    "javaVersion": 25, "gcType": "G1", "threads": 85, "classes": 30000,
    "stackSizeMiB": 1, "codeCacheMiB": 64, "directMemoryMiB": 10,
    "headroomPercent": 15, "heapMiB": 384
  },
  "breakdown": {
    "heap": 384, "metaspace": 147, "compressedClassSpace": 44,
    "codeCache": 64, "threadStacks": 85, "directMemory": 10,
    "gcStructures": 20, "jvmInternals": 70,
    "subtotal": 780, "headroom": 117, "containerTotal": 897
  },
  "flags": "-XX:+UseG1GC -Xms384m -Xmx384m -Xss1m -XX:ReservedCodeCacheSize=64m -XX:MaxDirectMemorySize=10m -XX:+ExitOnOutOfMemoryError",
  "flagsPercentage": "-XX:+UseG1GC -XX:InitialRAMPercentage=42.0 -XX:MaxRAMPercentage=42.0 -Xss1m -XX:ReservedCodeCacheSize=64m -XX:MaxDirectMemorySize=10m -XX:+ExitOnOutOfMemoryError",
  "containerLimitMiB": 897,
  "ramPercentage": 42
}

Sizing as code

The intended use: gate a deployment when the manifest limit falls below the computed footprint.

#!/bin/sh
# Fail the pipeline when the manifest limit is below the computed footprint.
LIMIT_MI=$(grep -A2 'limits:' deploy.yaml | grep memory | tr -dc '0-9')
NEEDED_MI=$(curl -sf "https://jvm.expert/api/size?gc=G1&heap=384&threads=200&classes=35000" \
  | jq '.breakdown.containerTotal')

if [ "$LIMIT_MI" -lt "$NEEDED_MI" ]; then
  echo "deploy.yaml limit ${LIMIT_MI}Mi < computed footprint ${NEEDED_MI}Mi" >&2
  exit 1
fi

Want the number as a visual instead? The same query renders as a compact card at /embed?heap=384&gc=G1&... — iframe-friendly and unindexed.