Reducing Memory Consumption in Spring Cloud Projects by Tuning JVM Settings in IntelliJ IDEA
This guide explains how to lower the high memory usage of Spring Cloud applications on low‑end machines by adjusting per‑project JVM options in IntelliJ IDEA, detailing the necessary -Xmx, -Xms, -Xmn and -Xss parameters and showing the resulting performance improvement.
Problem
When developing Spring Cloud applications, the combined services (Eureka, Stream, Sleuth, Config, RabbitMQ, OAuth2, etc.) can consume 1–1.5 GB of RAM on a 12 GB laptop, causing the IDE to freeze or crash, especially when multiple services are started simultaneously.
Solution
Adjust the JVM parameters for each project in IntelliJ IDEA to limit heap and stack sizes.
1. Edit Configurations in IDEA
Open the Edit Configurations dialog from the top‑right corner of IDEA and select the Spring Cloud project (or add it manually with the "+" button).
Set the JVM options according to the resources you want to allocate. Example configuration screenshots are omitted for brevity.
Typical allocations: Register service 128 M, Gateway and Config 256 M, other business services up to 512 M.
2. JVM Parameter Details
Reference links (e.g., http://blog.csdn.net/sdujava2011/article/details/50086933) describe the most common options: -Xmx – Maximum heap size (default ¼ of physical memory). Adjust based on total RAM. -Xms – Initial heap size. For servers, set equal to -Xmx; for development, defaults are fine. -Xmn – Young generation size; usually keep the default. -Xss – Thread stack size; default is acceptable for most cases.
Another common set of parameters (from https://www.cnblogs.com/w-wfy/p/6415856.html) includes: -Xms512m – Set initial heap to 512 M. -Xmx512m – Set maximum heap to 512 M. -Xmn200m – Young generation of 200 M (about 3/8 of total heap). -Xss128k – Reduce thread stack size to 128 KB (default after JDK 5 is 1 M).
Result
After applying the tuned JVM options, the same 12 GB machine can run 14 Spring Cloud services plus other tools (e.g., three IDEA instances) without exhausting memory, as shown by the post‑adjustment memory usage screenshot.
Thank you for reading; hope this helps! Source: blog.csdn.net/wanhuiguizong/article/details/79289986
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Selected Java Interview Questions
A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
