<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-much-memory-do-idle-database-connections-waste-i-ran-a-java-experiment-with-two-apps-sharing-po-fubsa1pfn" -->

---
title: How much memory do idle database connections waste? I...
description: An experiment with two Spring Boot instances using HikariCP against PostgreSQL shows that default pool sizing (minimumIdle = maximumPoolSize = 10) leaves 20...
canonical: https://daily.dev/posts/how-much-memory-do-idle-database-connections-waste-i-ran-a-java-experiment-with-two-apps-sharing-po-fubsa1pfn
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How much memory do idle database connections waste? I ran a Java experiment with two apps sharing PostgreSQL. Releasing 18 idle connections saved about 29 MiB of database memory, but reopening them came at a cost. | daily.dev
og:description: An experiment with two Spring Boot instances using HikariCP against PostgreSQL shows that default pool sizing (minimumIdle = maximumPoolSize = 10) leaves 20...
og:url: https://daily.dev/posts/how-much-memory-do-idle-database-connections-waste-i-ran-a-java-experiment-with-two-apps-sharing-po-fubsa1pfn
og:image: https://api.daily.dev/og/posts/fuBsa1PFN.png
og:image:alt: How much memory do idle database connections waste? I ran a Java experiment with two apps sharing PostgreSQL. Releasing 18 idle connections saved about 29 MiB of database memory, but reopening them came at a cost.
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How much memory do idle database connections waste? I ran a Java experiment with two apps sharing PostgreSQL. Releasing 18 idle connections saved about 29 MiB of database memory, but reopening them came at a cost.

**[Just Java](https://daily.dev/sources/justjava)** · [@ejboy](https://daily.dev/ejboy) · 14 upvotes · 3 comments

## Summary

An experiment with two Spring Boot instances using HikariCP against PostgreSQL shows that default pool sizing (minimumIdle = maximumPoolSize = 10) leaves 20 idle connections open during quiet periods, consuming about 57-58 MiB of PostgreSQL cgroup memory. Setting minimumIdle to 1 with a short idleTimeout let idle connections retire down to 2, cutting PostgreSQL cgroup memory to roughly 28-29 MiB. A control profile confirms that starting with a low minimumIdle alone doesn't help — only enabling idleTimeout actually releases connections opened during a burst. Reclaiming capacity comes with a cost: when traffic returned, connection acquisition took 194-207 ms versus under 3 ms for pools that retained connections, adding roughly 400-450 ms to total request latency. The author recommends sizing maximumPoolSize to real concurrency needs, setting minimumIdle to the connections worth keeping warm, and leaving idleTimeout enabled, while cautioning that PgBouncer is a separate tradeoff with its own session-handling caveats.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://pvrlabs.xyz/articles/spring-boot-jdbc-pool-reclaim.html>

## Community discussion

Top comments from developers on daily.dev.

**@pdfopsdev** · 1 upvotes

> 29MiB per 18 connections lines up with what I've seen, each backend process in postgres eats a few MB just for caches before you even touch work_mem. the reopen cost is why HikariCP's minimumIdle exists, you're trading memory for avoiding that TCP+auth handshake tax on every burst.

## Similar posts on daily.dev

- [Connection Pool Sizing, Measured: Why 48 Connections Beat 400](https://daily.dev/posts/connection-pool-sizing-measured-why-48-connections-beat-400-f0oqizynp) · The Infinity · 62 upvotes · 5 comments
- [All Your GUCs in a Row: max\_connections](https://daily.dev/posts/all-your-gucs-in-a-row-max-connections-32g7lgls2) · Planet PostgreSQL · 0 upvotes · 0 comments
- [PostgreSQL to SQL Field Notes: Connections](https://daily.dev/posts/postgresql-to-sql-field-notes-connections-qadiery02) · DevBlogs · 0 upvotes · 0 comments
- [Postgres Postmaster does not scale](https://daily.dev/posts/postgres-postmaster-does-not-scale-fee3cv3ni) · Hacker News · 45 upvotes · 1 comments

---

Tags: [#java](https://daily.dev/tags/java), [#database](https://daily.dev/tags/database), [#postgresql](https://daily.dev/tags/postgresql), [#spring-boot](https://daily.dev/tags/spring-boot)

[View this post on daily.dev](https://daily.dev/posts/how-much-memory-do-idle-database-connections-waste-i-ran-a-java-experiment-with-two-apps-sharing-po-fubsa1pfn)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/how-much-memory-do-idle-database-connections-waste-i-ran-a-java-experiment-with-two-apps-sharing-po-fubsa1pfn","headline":"How much memory do idle database connections waste? I ran a Java experiment with two apps sharing PostgreSQL. Releasing 18 idle connections saved about 29 MiB of database memory, but reopening them came at a cost.","text":"Shared: Spring Boot Connection Pools: 20 vs 2 Idle PostgreSQL Connections","url":"https://daily.dev/posts/how-much-memory-do-idle-database-connections-waste-i-ran-a-java-experiment-with-two-apps-sharing-po-fubsa1pfn","datePublished":"2026-10-13T16:33:43.073Z","dateModified":"2026-10-13T16:33:43.077Z","author":{"@type":"Person","name":"Ted K","url":"https://daily.dev/ejboy","image":"https://media.daily.dev/image/upload/s--PzSRqJKu--/f_auto/v1787843390/avatars/avatar_Szw3t3q8eJYj5aTperuyF?_a=BAMAMicg0","description":"Building lightweight developer tools at PVR Labs.","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":1140}},"image":"https://media.daily.dev/image/upload/s--0_ODbtD2--/f_auto/v1722860399/public/Placeholder%2008","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":14},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":3}],"sharedContent":{"@type":"WebPage","url":"https://api.daily.dev/r/67Jc5tWOb"},"comment":[{"@type":"Comment","text":"29MiB per 18 connections lines up with what I’ve seen, each backend process in postgres eats a few MB just for caches before you even touch work_mem. the reopen cost is why HikariCP’s minimumIdle exists, you’re trading memory for avoiding that TCP+auth handshake tax on every burst.","datePublished":"2026-10-14T18:05:36.677Z","url":"https://daily.dev/posts/fuBsa1PFN#c-52rGetW03","author":{"@type":"Person","name":"PDFops","url":"https://daily.dev/pdfopsdev","image":"https://media.daily.dev/image/upload/s---8isRBKc--/f_auto/v1782922291/avatars/avatar_orjMeK8QKaaVZwGq7ScPz?_a=BAMAMicg0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/squads/justjava","name":"Just Java"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Just Java","item":"https://daily.dev/squads/justjava"},{"@type":"ListItem","position":3,"name":"How much memory do idle database connections waste? I ran a Java experiment with two apps sharing PostgreSQL. Releasing 18 idle connections saved about 29 MiB of database memory, but reopening them came at a cost."}]}
```

