db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Tripp" <dtr...@activecore.com>
Subject RE: Leaky behaviour on insert?
Date Thu, 27 Oct 2005 02:30:53 GMT
Sorry for the crappy formatting of the code in my original mail.  I hope
this one is better:


** InsertLots.java **

import java.util.*;
import java.sql.*;
import org.apache.derby.jdbc.EmbeddedDriver;

public class InsertLots {
  static public void main(String args_[]) throws Exception {
    new EmbeddedDriver();
    Connection conn = DriverManager.getConnection(
      "jdbc:derby:testdb;create=true");
    try {
      conn.createStatement().execute(
        "CREATE TABLE leaktesttable (time VARCHAR(100) )");
    } catch(SQLException e) {} // in case table already exists 
    
    PreparedStatement stmt = conn.prepareStatement(
      "INSERT into leaktesttable values (?)");
    for(int i=0; true; ++i) {
      stmt.setString(1, (new java.util.Date()).toString());
      stmt.execute();
      if(i % 5000 == 0) {
        System.gc();
        System.out.println(
          ""+i+": "+Runtime.getRuntime().totalMemory());
      }
    }
  }
}



Mime
View raw message