# Java Resource Management: JVM-Aware Rightsizing | LevelFour

> Java resource management for Kubernetes. LevelFour reads each JVM's heap, cuts memory to what it needs, and fixes OOM kills in place, with no restart.

Source: https://levelfour.ai/java-resource-management

Updated: 2026-11-23

Cut Java memory waste without OOM kills.

LevelFour finds the JVMs on your clusters and reads each heap from the pod spec or, with the optional JVM reader, from the running JVM: the heap it may grow to, its live set and the memory it holds outside the heap. Then it sizes each Java pod to fit and ships the change, in place or as a pull request.

[Read the docs](https://docs.levelfour.ai/connectors/kubernetes/recommendations#jvm-heap)

## JVM-aware by design

A JVM reserves memory up front and can grow its heap to -Xmx at any moment. Size a Java pod from last week's usage and the next busy hour ends in an OOM kill. LevelFour sizes every Java container from its heap, so no memory cut goes below what the JVM can claim: the heap maximum, plus 256 MiB and a tenth of the heap for everything outside it.

- **See inside every JVM**: Turn on the optional JVM reader and each Java container shows its heap maximum, an upper bound on its live set, committed heap, memory outside the heap, time in GC pauses and JDK, day by day, next to its requests and limits. LevelFour also flags what wastes memory, such as a heap far above its live set or one left at the JVM's default 25% on a large limit.
- **OOM kills fixed in place**: After two OOM kills of a container within an hour, the automation gives the running pod up to 25% more memory, with no restart. The chart marks the raise, and the days after show whether it held.
- **Rightsized in place, one step at a time**: Where you turn automation on, LevelFour cuts a request by at most 20% a step on the running pods and stops at the memory floor. It never lowers a JVM's limits, and a pod that is OOM killed, evicted, restarts twice in an hour or stops being ready goes back on its own. [How the automation works](https://docs.levelfour.ai/connectors/kubernetes/automation)
- **Or as a pull request**: Each change can ship as a pull request on the repository that deploys the workload, with the HPA or KEDA target moved in the same diff. Your pipeline applies it, and a week later LevelFour measures the saving on your bill.

## How LevelFour sizes the JVM

The docs cover the memory floor, the CPU rules for older JDKs, what the agent reads from each container and the automation's guardrails.

[Read the docs](https://docs.levelfour.ai/connectors/kubernetes/recommendations#jvm-heap)

## Java resource management FAQ

### How does LevelFour prevent OOM kills on Java pods?

No memory cut goes below the JVM's memory floor: the heap maximum, plus 256 MiB and a tenth of the heap for memory outside it. A JVM whose heap LevelFour cannot read gets no memory cut. After OOM kills, the automation raises the container's memory in place.

### Which Java workloads does LevelFour find?

Every container that shows a JVM's signs: a JVM's name in its image or command line, an option only a JVM takes, or a variable such as JAVA_TOOL_OPTIONS, JAVA_OPTS or JVM_OPTS. Spring Boot services and Tomcat, Jetty or WildFly apps all count, with no setup per app. With the optional JVM reader on, LevelFour also finds a HotSpot JVM whatever its image is called.

### What JVM metrics does LevelFour show?

From the pod spec, each container's -Xmx and -Xms where the command line sets them. With the optional JVM reader on, for each HotSpot JVM: the heap it may grow to, an upper bound on its live set, committed heap, memory outside the heap, metaspace, time in GC pauses, the JDK version and the collector, day by day.

### Does LevelFour change my JVM flags?

No. LevelFour sizes the container around the JVM: it changes requests, raises memory after OOM kills, and never lowers a JVM's limits, since a running JVM keeps the heap and collector it picked at start.

### How do I set it up?

Install the LevelFour agent with one Helm command, or across clusters with Argo CD, Flux or Terraform. LevelFour finds your Java workloads on its own. To measure heaps your specs don't show, turn on the optional JVM reader in the same chart.

## About LevelFour

The FinOps platform that actually cuts costs. One system of record for Cloud, SaaS, and AI spend. LevelFour applies each saving, or your engineers merge it as code.

- **Cloud Savings**: 30% success fee on savings found and applied. No hidden charges, only pay on what you actually save.
- **Pro**: $30 per month · Up to $2,500 spend/mo
- **Scale**: $200 per month · Up to $7,500 spend/mo
- **Enterprise**: Custom · Unlimited spend

[Pricing](https://levelfour.ai/pricing.md) · [Guide for agents (llms.txt)](https://levelfour.ai/llms.txt) · [Documentation](https://docs.levelfour.ai) · MCP server: `https://mcp.levelfour.ai/mcp`
