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

来源:互联网 发布:淘宝2017双十一交易 编辑:程序博客网 时间:2024/06/08 08:02

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
原创粉丝点击