Diagnosing High Memory Usage in Spring Boot Applications: JVM Parameters and Troubleshooting Steps

The article details how a production Spring Boot system consumed excessive memory due to default JVM heap settings, explains the underlying JVM defaults, demonstrates diagnostic commands, and provides practical recommendations for configuring JVM parameters and monitoring memory usage to prevent similar issues.

Top Architect
Top Architect
Top Architect
Diagnosing High Memory Usage in Spring Boot Applications: JVM Parameters and Troubleshooting Steps

In production we observed Spring Boot services consuming ~12GB each on a 64GB server, causing apparent hangs.

We reproduced the issue locally and used jps and jmap -heap to inspect process IDs and heap usage, discovering the maximum heap size was set to 4GB while the actual JVM allocated up to 12GB due to default settings.

The default JVM heap size (-Xmx) is typically one‑quarter of physical memory, and the initial heap size (-Xms) one‑sixty‑fourth; on servers with large memory these defaults can lead to excessive allocation.

We listed the official Oracle defaults for client and server JVMs, explained how they differ based on 32‑bit vs 64‑bit and memory thresholds, and highlighted that the young generation occupies roughly one‑third of the total heap.

To avoid waste, we recommend explicitly configuring JVM parameters according to application needs and server capacity, monitoring memory usage, analyzing GC logs, and using tools such as VisualVM or MAT for deeper analysis.

General troubleshooting steps for high memory usage include checking JVM flags, observing heap and non‑heap usage, analyzing garbage collection, setting appropriate heap limits, and employing memory‑analysis tools.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaJVMMemory ManagementBackend DevelopmentSpringBoot
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

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.