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.
| Param | Type | Default | Semantics |
|---|---|---|---|
| v | 21 | 25 | 25 | Java version the model targets. |
| gc | G1 | ZGC | Serial | Parallel | G1 | Garbage collector — changes the native GC-structures estimate. |
| mode | heap | container | heap | heap: you provide the heap, the API derives the limit. container: you provide the limit, the API solves the largest heap that fits. |
| heap | number (MiB) | 384 | Desired heap (-Xmx). Used in heap mode only. |
| limit | number (Mi) | 1024 | Container memory limit. Used in container mode only. |
| threads | number | 85 | Expected platform threads (stacks are counted as reserved upper bound: threads × xss). |
| classes | number | 30000 | Expected loaded classes — drives the metaspace and internals estimates. |
| xss | number (MiB) | 1 | Stack size per thread (-Xss). |
| cc | number (MiB) | 64 | ReservedCodeCacheSize. |
| dm | number (MiB) | 10 | MaxDirectMemorySize. |
| hr | number (%) | 15 | Headroom 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
}containerLimitMiB— in heap mode, the recommended limit; in container mode, the limit you passed.flagsvsflagsPercentage— fixed-Xms/-Xmxstyle and the computedMaxRAMPercentagestyle (recommended in containers).400— malformed parameter,{ "error": "..." }.422— container mode with a limit too small for any heap.
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
fiWant the number as a visual instead? The same query renders as a compact card at /embed?heap=384&gc=G1&... — iframe-friendly and unindexed.