Subject ResultSet memory issue
Author Ramon Rockx
Hi all,

Does anybody know when the memory which is reserved for a ResultSet is
released?
When I run a piece of code (which can be found on the end of this email) on
a table with 10000 records it
gives the following result:

Autocommit: true
Memory before selects 413 kB
Memory after selects 186787 kB
Memory after close connection 186787 kB

What I expected was that the memory would be released after the resultset is
closed. However, even when the connection is closed, the memory is not
released.

Can somebody help me out with this?

Regards,

Ramon Rockx


public static void testSQL() {
try {
long memoryBeforeSelects;
long memoryAfterSelects;
long memoryAfterConnectionClose;

Class.forName("org.firebirdsql.jdbc.FBDriver");
Connection conn =
DriverManager.getConnection("jdbc:firebirdsql:localhost/3050:D:\\memorytest.fdb",
"sysdba", "masterkey");
System.out.println("Autocommit: " + conn.getAutoCommit());
try {
Statement stmt = conn.createStatement();
stmt.setFetchSize(10);
try {
System.gc();
memoryBeforeSelects = Runtime.getRuntime().totalMemory() -
Runtime.getRuntime().freeMemory();
ResultSet rs = stmt.executeQuery("SELECT * FROM
TEST_TABLE");
rs.close();
System.gc();
memoryAfterSelects = Runtime.getRuntime().totalMemory() -
Runtime.getRuntime().freeMemory();
}
finally {
stmt.close();
}
}
finally {
conn.close();
System.gc();
memoryAfterConnectionClose =
Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
}
System.out.println("Memory before selects " + memoryBeforeSelects /
1024 + " kB");
System.out.println("Memory after selects " + memoryAfterSelects /
1024 + " kB");
System.out.println("Memory after close connection " +
memoryAfterConnectionClose / 1024 + " kB");
}
catch (Exception ex) {
ex.printStackTrace();
}
}




---------------------------------
Do you Yahoo!?
Meet the all-new My Yahoo! � Try it today!

[Non-text portions of this message have been removed]