Backend Development 9 min read

Measuring Per-Request Heap Memory Usage in SpringBoot Applications

The article details a SpringBoot experiment that uses JMeter to send 20,000 HTTP requests, captures detailed GC logs, and demonstrates that each request consumes roughly 34 KB of heap memory, with larger payloads and logging increasing the usage, highlighting the importance of memory‑aware coding and log management.

Top Architect
Top Architect
Top Architect
Measuring Per-Request Heap Memory Usage in SpringBoot Applications

In this article, a senior architect demonstrates how to measure the heap memory allocated by a single HTTP or RPC request in a SpringBoot 2.5.4 application.

The experiment creates a new SpringBoot project, adds a POST endpoint and a GET endpoint for triggering GC, then uses JMeter to send 20,000 POST requests with 10 threads, each looping 2,000 times. GC logs are enabled with detailed options.

After the load test, the author calculates the memory increase in the young generation. The results show that each HTTP request consumes about 34 KB of heap memory even when the request body is only 50 characters. Adding a larger payload (1200 characters) raises the consumption to roughly 36 KB, and enabling detailed request logging further increases it to about 56 KB.

The article also explains how to configure JVM options such as -Xmx4g -Xms4g -XX:SurvivorRatio=8 -Xmn2g and enable GC logging with -Xloggc:/path/to/gc.log , and how to trigger manual GC via curl http://localhost:8080/gc .

From the data, the author concludes that SpringBoot creates multiple internal objects per request, leading to memory usage far exceeding the raw payload size, and recommends limiting log size to avoid unnecessary GC overhead.

Finally, the author invites readers to discuss the findings and promotes a community for sharing ChatGPT‑related resources, though this part is promotional.

backendJVMperformanceJMeterSpringBootMemoryGC
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.