Subject | Re: [Firebird-Java] Memory buildup |
---|---|
Author | Roman Rokytskyy |
Post date | 2004-10-26T23:34:56Z |
>> Sorry, I think i did not express my self clearly.I have used following code to reproduce your issue:
>>
>> We do use both ResultSet.close() and Statement.close(), but they do
>> NOT make the cleanup. I believe this is a bug in JayBird.
>
> Ok, I will try to check this.
int recordCount = 100;
PreparedStatement ps =
connection.prepareStatement(
"INSERT INTO test_table(" +
"id, very_long_str) VALUES (?, ?)");
try {
Random rnd = new Random();
byte[] string = new byte[19000];
rnd.nextBytes(string);
for(int i = 0; i < recordCount; i++) {
ps.setInt(1, i);
ps.setBytes(2, string);
ps.executeUpdate();
}
} finally {
ps.close();
}
connection.setAutoCommit(false);
long memoryBefore = Runtime.getRuntime().totalMemory();
int selectRuns = 10000;
for(int i = 0; i < selectRuns; i++) {
Statement stmt = connection.createStatement();
try {
ResultSet rs = stmt.executeQuery(
"SELECT * FROM test_table");
while(rs.next()) {
// just loop through result set
}
} finally {
stmt.close();
}
}
System.gc();
long memoryAfter = Runtime.getRuntime().totalMemory();
System.out.println("Memory before " + memoryBefore +
", memory after " + memoryAfter + ", difference " +
((memoryAfter - memoryBefore) / 1024 /1024));
connection.commit();
System.gc();
memoryAfter = Runtime.getRuntime().totalMemory();
System.out.println("Memory before " + memoryBefore +
", memory after " + memoryAfter + ", difference " +
((memoryAfter - memoryBefore) / 1024 /1024));
However the difference before the connection.commit() and after the
connection.commit() is almost the same.
Since this code does not reproduce your issue, would you be so kind to
create a test case that shows the memory growth.
Thanks!
Roman