// Author: Sandeep Belgavi. Hypothetical MiB planning arithmetic, not process measurement.
public class JvmBudgetDemo {
    public static void main(String[] args) {
        long limit = 2048, heap = 1536, direct = 128;
        long platformThreads = 128, stackKiB = 1024, otherNative = 256, reserve = 128;
        double stackMiB = platformThreads * stackKiB / 1024.0;
        double planned = heap + direct + stackMiB + otherNative + reserve;
        double headroom = limit - planned;
        if (headroom != -128.0) throw new AssertionError("Arithmetic changed");
        System.out.printf(java.util.Locale.ROOT,
                "planned=%.1f MiB headroom=%.1f MiB budget_exceeded=%s%n",
                planned, headroom, headroom < 0);
    }
}
