[I] [BUG] hikari连接池泄露问题 [hertzbeat]</span></a></span> </h1> <p class="darkgray font13"> <span class="sender pipe"><a href="/search?l=notifications@hertzbeat.apache.org&q=from:%22via+GitHub%22" rel="nofollow"><span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">via GitHub</span></span></a></span> <span class="date"><a href="/search?l=notifications@hertzbeat.apache.org&q=date:20260625" rel="nofollow">Thu, 25 Jun 2026 03:25:16 -0700</a></span> </p> </div> <div itemprop="articleBody" class="msgBody"> <!--X-Body-of-Message--> <pre> zhaoguangqin opened a new issue, #4181: URL: <a rel="nofollow" href="https://github.com/apache/hertzbeat/issues/4181">https://github.com/apache/hertzbeat/issues/4181</a></pre><pre> ### Is there an existing issue for this? - [x] I have searched the existing issues ### Current Behavior 导出hertzbeat dump文件,分析如下: Class Name | Objects | Shallow Heap | Retained Heap ---------------------------------------------------------------------------------------- | | | byte[] | 396,159 | 49.56 MB | >= 49.56 MB org.postgresql.jdbc.PgConnection | 819 | 0.10 MB | >= 38.84 MB java.lang.ref.Finalizer | 1,149 | 0.04 MB | >= 38.41 MB java.lang.Object[] | 59,737 | 6.01 MB | >= 30.34 MB java.util.concurrent.ConcurrentHashMap | 5,735 | 0.35 MB | >= 26.61 MB java.util.concurrent.ConcurrentHashMap$Node[]| 3,296 | 1.54 MB | >= 26.31 MB java.lang.String | 377,327 | 8.64 MB | >= 25.11 MB java.util.HashMap$Node[] | 41,292 | 5.56 MB | >= 24.98 MB java.util.HashMap | 22,951 | 1.05 MB | >= 24.38 MB java.util.concurrent.ConcurrentHashMap$Node | 125,723 | 3.84 MB | >= 23.15 MB java.util.ArrayList | 29,540 | 0.68 MB | >= 22.96 MB java.util.HashMap$Node | 467,433 | 14.26 MB | >= 19.48 MB org.postgresql.core.v3.QueryExecutorImpl | 819 | 0.17 MB | >= 18.77 MB org.postgresql.jdbc.TypeInfoCache | 819 | 0.07 MB | >= 18.36 MB java.util.zip.ZipFile$Source | 437 | 0.03 MB | >= 17.49 MB ---------------------------------------------------------------------------------------- PgConnection 的对象高达819个,占用38MB的空间,随着时间的增长还会越来越多 查看持有PgConnection对象的引用如下: Class Name | Objects | Shallow Heap ------------------------------------------------------------------- org.postgresql.jdbc.PgConnection | 819 | 0.10 MB |- org.postgresql.jdbc.TypeInfoCache | 819 | 0.07 MB |- org.postgresql.jdbc.PgPreparedStatement| 457 | 0.05 MB |- java.lang.ref.Finalizer | 819 | 0.03 MB |- com.zaxxer.hikari.pool.PoolEntry | 10 | 0.00 MB '- Total: 4 entries | | ------------------------------------------------------------------- 从上可以看出,819个PgConnection处于未关闭,对象一直未释放 修改如下: `spring: datasource: hikari: maximum-pool-size: 20 # 限制最大连接数 minimum-idle: 5 # 最小空闲连接 idle-timeout: 60000 # 空闲 60s 回收 max-lifetime: 120000 # 连接最长存活 120s (保留) connection-timeout: 30000 # 获取连接超时 30s leak-detection-threshold: 5000 # ⚠️ 泄漏检测 5s (之前是 60s,建议 5s) connection-test-query: SELECT 1 # 连接测试查询 ` 添加以上配置之后,连接池PgConnection对象个数稳定下来,内存利用率稳定下来 ### Expected Behavior _No response_ ### Steps To Reproduce _No response_ ### Environment ```markdown HertzBeat version(s):1.8.0 ``` ### Debug logs _No response_ ### Anything else? _No response_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@hertzbeat.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@hertzbeat.apache.org For additional commands, e-mail: notifications-h...@hertzbeat.apache.org </pre> </div> <div class="msgButtons margintopdouble"> <ul class="overflow"> <li class="msgButtonItems"><a class="button buttonleft " accesskey="p" href="msg16453.html">Previous message</a></li> <li class="msgButtonItems textaligncenter"><a class="button" accesskey="c" href="index.html#16454">View by thread</a></li> <li class="msgButtonItems textaligncenter"><a class="button" accesskey="i" href="maillist.html#16454">View by date</a></li> <li class="msgButtonItems textalignright"><a class="button buttonright " accesskey="n" href="msg16525.html">Next message</a></li> </ul> </div> <a name="tslice"></a> <div class="tSliceList margintopdouble"> <ul class="icons monospace"> <li class="icons-email tSliceCur"><span class="subject">[I] [BUG] <title> hikari连接池泄露问题 [hertzbeat]</span> <span class="sender italic">via GitHub</span></li> <li><ul> <li class="icons-email"><span class="subject"><a href="msg16525.html">Re: [I] [BUG] PgConnection连接未释放,内存泄露问题 [hertzbeat]</a></span> <span class="sender italic">via GitHub</span></li> </ul> </ul> </div> <div class="overflow msgActions margintopdouble"> <div class="msgReply" > <h2> Reply via email to </h2> <form method="POST" action="/mailto.php"> <input type="hidden" name="subject" value="[I] [BUG] <title> hikari连接池泄露问题 [hertzbeat]"> <input type="hidden" name="msgid" value="I_kwDOGyeqAs8AAAABGrNbIA@gitbox.apache.org"> <input type="hidden" name="relpath" value="notifications@hertzbeat.apache.org/msg16454.html"> <input type="submit" value=" via GitHub "> </form> </div> </div> </div> <div class="aside" role="complementary"> <div class="logo"> <a href="/"><img src="/logo.png" width=247 height=88 alt="The Mail Archive"></a> </div> <form class="overflow" action="/search" method="get"> <input type="hidden" name="l" value="notifications@hertzbeat.apache.org"> <label class="hidden" for="q">Search the site</label> <input class="submittext" type="text" id="q" name="q" placeholder="Search notifications"> <input class="submitbutton" name="submit" type="image" src="/submit.png" alt="Submit"> </form> <div class="nav margintop" id="nav" role="navigation"> <ul class="icons font16"> <li class="icons-home"><a href="/">The Mail Archive home</a></li> <li class="icons-list"><a href="/notifications@hertzbeat.apache.org/">notifications - all messages</a></li> <li class="icons-about"><a href="/notifications@hertzbeat.apache.org/info.html">notifications - about the list</a></li> <li class="icons-expand"><a href="/search?l=notifications@hertzbeat.apache.org&q=subject:%22%5C%5BI%5C%5D+%5C%5BBUG%5C%5D+%3Ctitle%3E+hikari%E8%BF%9E%E6%8E%A5%E6%B1%A0%E6%B3%84%E9%9C%B2%E9%97%AE%E9%A2%98+%5C%5Bhertzbeat%5C%5D%22&o=newest&f=1" title="e" id="e">Expand</a></li> <li class="icons-prev"><a href="msg16453.html" title="p">Previous message</a></li> <li class="icons-next"><a href="msg16525.html" title="n">Next message</a></li> </ul> </div> <div class="listlogo margintopdouble"> </div> <div class="margintopdouble"> </div> </div> </div> <div class="footer" role="contentinfo"> <ul> <li><a href="/">The Mail Archive home</a></li> <li><a href="/faq.html#newlist">Add your mailing list</a></li> <li><a href="/faq.html">FAQ</a></li> <li><a href="/faq.html#support">Support</a></li> <li><a href="/faq.html#privacy">Privacy</a></li> <li class="darkgray">I_kwDOGyeqAs8AAAABGrNbIA@gitbox.apache.org</li> </ul> </div> </body> </html>