提交 14d5d0dc authored 作者: Thomas Mueller's avatar Thomas Mueller

There was a memory leak in the trace system. Opening and closing many…

There was a memory leak in the trace system. Opening and closing many connections could run out of memory.
上级 fa22709e
...@@ -140,7 +140,7 @@ public class TraceSystem implements TraceWriter { ...@@ -140,7 +140,7 @@ public class TraceSystem implements TraceWriter {
*/ */
public synchronized Trace getTrace(String module) { public synchronized Trace getTrace(String module) {
if (module.endsWith("]")) { if (module.endsWith("]")) {
new Trace(writer, module); return new Trace(writer, module);
} }
if (traces == null) { if (traces == null) {
traces = New.hashMap(16); traces = New.hashMap(16);
......
...@@ -33,6 +33,7 @@ public class TestMemoryUsage extends TestBase { ...@@ -33,6 +33,7 @@ public class TestMemoryUsage extends TestBase {
} }
public void test() throws SQLException { public void test() throws SQLException {
testOpenCloseConnections();
if (getBaseDir().indexOf(':') >= 0) { if (getBaseDir().indexOf(':') >= 0) {
// can't test in-memory databases // can't test in-memory databases
return; return;
...@@ -50,6 +51,22 @@ public class TestMemoryUsage extends TestBase { ...@@ -50,6 +51,22 @@ public class TestMemoryUsage extends TestBase {
deleteDb("memoryUsage"); deleteDb("memoryUsage");
} }
private void testOpenCloseConnections() throws SQLException {
if (!config.big) {
return;
}
deleteDb("memoryUsage");
conn = getConnection("memoryUsage");
eatMemory(4000);
for (int i = 0; i < 40000; i++) {
Connection c2 = getConnection("memoryUsage");
c2.createStatement();
c2.close();
}
freeMemory();
conn.close();
}
private void testCreateDropLoop() throws SQLException { private void testCreateDropLoop() throws SQLException {
deleteDb("memoryUsage"); deleteDb("memoryUsage");
conn = getConnection("memoryUsage"); conn = getConnection("memoryUsage");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论