java.lang.OutOfMemoryError:GC overhead limit exceeded c3p0 mysql connection版本 Druid HttpClient正确关闭

1, 配置参数可以加上 增加参数,-XX:-UseGCOverheadLimit

2, mysql connection 版本如果小于5.1.10 有个内存bug

3,c3p0 连接池等数据库连接池,如果程序内部没处理好, 可能会出现连接一直存在,最后连接不够, 可以用开源的阿里巴巴 mysql连接 Druid, 设置removeAbandoned=true,removeAbandonedTimeout=600(10分钟), 

Druid可能是现在最好的数据库连接池~~~

4,HttpClient (Apache的4.x及以上)要正确关闭get/post,和entity

HttpResponse resp = null;
try {
resp = client.execute(httpGet);
if (resp.getStatusLine().getStatusCode() == 200) {
isPostBackSucc = true;
}
} catch (Throwable e) {
logger.error("error", e);
} finally {
try {
httpGet.abort();//这里要调用
} catch (Exception e) {
}
if (resp != null) {
try {
EntityUtils.consumeQuietly(resp.getEntity());//这里要关闭
} catch (Exception e) {
}
}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值