druid 1.0.15会导致内存泄露

bxfogqkk  于 2021-11-27  发布在  Java
关注(0)|答案(3)|浏览(808)

运行3天左右,tomcat内存为2048
老年代占用1200M,共1700M
其中class java.util.LinkedHashMap$Entry 共占用接近800M

查看截图:
http://postimg.org/image/4dkhe2di5/
http://postimg.org/image/7lpwtv86h/

java.util.LinkedHashMap$Entry @ 0x7c6ca09b8
class java.util.LinkedHashMap$Entry @ 0x77f730b60
com.alibaba.druid.pool.PreparedStatementPool$LRUCache @ 0x7bedc9f90
java.util.LinkedHashMap$Entry @ 0x7bee56788
java.util.LinkedHashMap$Entry @ 0x7c6ca0930
com.alibaba.druid.pool.DruidPooledPreparedStatement$PreparedStatementKey @ 0x7c6ca09e0
class com.alibaba.druid.pool.DruidPooledPreparedStatement$PreparedStatementKey @ 0x7824db290
com.alibaba.druid.pool.PreparedStatementPool$MethodType @ 0x780630208
calm_online
select id,synFlag serverId,unix_timestamp(modifyDateTime) syncState,'0' as isOk,createDateTime,status deleted,brandId,commercialId,orderType,orderSynFlag,reasonType,reasonSynFlag reasonId,reasonMemo from order_reasons where commercialId=? and modifyDateTime > FROM_UNIXTIME(1442399564) order by modifyDateTime asc limit 1000
com.alibaba.druid.pool.PreparedStatementHolder @ 0x7c6ca0a10
class com.alibaba.druid.pool.PreparedStatementHolder @ 0x780baa5b0
com.alibaba.druid.pool.DruidPooledPreparedStatement$PreparedStatementKey @ 0x7c6ca09e0
com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl @ 0x7c6ca0a40

whlutmcx

whlutmcx1#

我也遇到同样的问题,druid版本1.1.2,最后有解决方案吗?

gz5pxeao

gz5pxeao2#

1.0.16也有这个问题,老年代吃光

46qrfjad

46qrfjad3#

pool-prepared-statements: false
      max-pool-prepared-statement-per-connection-size: -1

如果你使用的mysql的话这个关了能解决问题

if (stmt.isPooled() && holder.isPoolPreparedStatements() && stmt.exceptionCount == 0) {
            holder.getStatementPool().put(stmtHolder);
...
}
这样就不会进到缓存,缓存PreparedStatements对于很少执行相同sql的场景来说没有很大的意义

相关问题