Backend Development 8 min read

Diagnosing High Memory Usage in Spring Boot Applications: JVM Parameters and Best Practices

This article records and reviews a production incident where multiple Spring Boot services consumed excessive memory, explains how default JVM settings caused each instance to allocate up to 12 GB of heap, and provides step‑by‑step diagnostics, configuration guidelines, and optimization recommendations for backend developers.

Top Architect
Top Architect
Top Architect
Diagnosing High Memory Usage in Spring Boot Applications: JVM Parameters and Best Practices

In a production environment the author observed that several Spring Boot micro‑services each consumed nearly 12 GB of memory on a 64 GB server, leading to application stalls.

Background : After a period of stable operation, increased traffic caused Java processes to use excessive heap memory, revealing that default JVM parameters were applied.

Solution Steps :

Use jps or top to identify process IDs.

Run jmap -heap <PID> to view heap configuration; the maximum heap was set to 4 GB while the application actually used 12 GB.

The investigation showed that the default maximum heap size (-Xmx) is typically one‑quarter of physical memory, and the initial heap size (-Xms) is one‑sixty‑fourth, which can be unsuitable for server workloads.

JVM Default Parameters (from Oracle documentation):

Client JVM: max heap = 1/4 of physical memory (or 1/2 if memory ≤ 192 MB); min heap = at least 8 MB or 1/64 of memory.

Server JVM: similar rules but can allocate larger heaps; on 64‑bit JVMs with ≥ 128 GB RAM, max heap can reach 32 GB.

Because the production services were started without explicit JVM options, they inherited these defaults, causing the high memory consumption.

Post‑mortem Recommendations :

Review and set appropriate JVM parameters (-Xms, -Xmx) based on application needs and server capacity.

Monitor memory usage with OS tools or APM solutions, including heap, non‑heap, and GC metrics.

Analyze GC logs to understand collection frequency and pause times.

Consider using profiling tools such as VisualVM or MAT to detect memory leaks or large objects.

Properly configuring JVM settings can prevent unnecessary resource waste and improve stability of backend services.

backendJavaJVMMicroservicesSpringBootMemoryOptimization
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.