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());
      }
    }
  }
}


Reply via email to