I'm trying a simple scala code in play framework 2.0 to fill my db (other options exists, such as importing a SQL file directly within the database, but that's not the point) :

```
def filldb = Action {
  import play.api.db.DB
  import anorm._

  var result: Boolean = false

  val tuples: List[(Long, String)] = DB
    .withConnection("playground") { implicit c =>

      for (i <- 1 until 1000000) {
        SQL("""
            INSERT INTO article (
                id,
                title
            ) VALUES (
                """ + i + """,
                'Article no """ + i + """');"""
        ).executeUpdate()

        if (i % 1000 == 0) println("i:" + i)
      }

      val sqlQuery = SQL("select id, title from article order by id;")

      sqlQuery().map(row =>
        row[Long]("id") -> row[String]("title")).toList
    }
  Ok("done")
}

```

This runs well for a while (200K iterations), slows down, eats up memory progressively (up to 1.8GB), and finally crashes from lack of memory.

Can someone explain me what causes this behaviour?
It's clear that it's possible to code it in different ways, but the point is to understand what is wrong, so that the error would not be done in another context...

To be complete, here are the details : 

* OS : mac 10.6.8
* play : 2.0
* database : mysql 5.5.12
* table : 

```
CREATE TABLE article (
id bigint(20) NOT NULL UNIQUE,
title varchar(255) NOT NULL,
PRIMARY KEY (id)
);

```

Tried this as weel, with no more success :

```
def filldb = Action {
  import play.api.db.DB
  import anorm._

  var result: Boolean = false
  val connection = DB.getConnection("playground")

  for (i <- 1 until 1000000) {
        SQL("""
            INSERT INTO article (
                id,
                title
            ) VALUES (
                """ + i + """,
                'Article no """ + i + """');"""
        ).executeUpdate()(connection)

        if (i % 1000 == 0) println("i:" + i)
      }

  val tuples: List[(Long, String)] = {

      val sqlQuery = SQL("select id, title from article order by id;")

      sqlQuery()(connection).map(row =>
        row[Long]("id") -> row[String]("title")).toList
    }

  connection.close()

  Ok("done")
}

```

Not better : stuck at 283k iterations...