Chris Smith wrote:
> Over the weekend, I had the pleasure to find the location of an enormous
> memory leak in Interbase. I searched the newsgroups, and other threads
> related to IB, and found several people complaining about such leaks.
> However, all of the responses from Borland folks have stated that the issue
> was due to unclosed connections, etc.
> Well, I have a reproducible test case that is only a couple lines.
> My configuration is as follows:
> Interbase 6.01 (Open Source)
> Interbase Client 1.60 (I have also reproduced with 2.0) (Open Source)
> JDBC Drivers 1.60
> Windows 2000
> The problem appears to show itself when using JDBC Statement operations that
> perform updates (delete, update, etc.). Here is the sample code that will
> allow you to deplete your computer of all its memory.
> try
> {
> Connection con = /* Create JDBC connection here using
> "interbase.interclient.Driver" */
> for( int i = 0; i < 1000; i++ )
> {
> int newVal = (int)(Math.random() * 100000);
> Statement st = con.createStatement();
> st.executeUpdate( "update foo set foocol = " + newVal + " where
> foocol > 0" );
> st.close();
> con.commit();
> }
> con.close();
> }
> catch( Exception e )
> {
> e.printStackTrace();
> }
> The DDL is the following: create table foo( foocol integer );
> I insert a row before testing, but it doesn't matter, the leak occurs in
> either case.
> When you run this program, watch the memory consumption of ibserver.exe and
> interserver.exe (the connection). Both of these processes will leak memory
> at a huge rate. When the program exits, none of the memory is reclaimed.
> The most interesting part is that if you change the Statement above to a
> PreparedStatement, the processes hardly leak at all. If they do leak it is
> at a very low rate.
> If there is anything I am missing, or something I am doing wrong, please let
> me know.
> --Chris.