RawrUniversal / xerial

Automatically exported from code.google.com/p/xerial
0 stars 1 forks source link

Significant memory consumption #74

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I noticed significant memory usage by sqlite in my Java application.
Then I tried the following simple code on both windows and snow
leopard (maximum heap size is set to 64m by "-Xmx64m"):

public class Main {
   public static void main(String[] args)
   {
       try {
           Class.forName("org.sqlite.JDBC");
           Connection c =
DriverManager.getConnection("jdbc:sqlite:foo.db"); // foo.db is an
empty db
           while (true) {
               Statement stmt = c.createStatement();
               stmt.close();
           }
       } catch (Exception e) {
       }
   }
}

The memory consumption of this code was surprisingly high, reaching
80MB on windows and 100MB on mac within a few seconds. However, if I
deleted the while loop, the consumption stayed at 8MB/32MB. In any
case, JVM's memory usage was below 64MB (verified using jconsole).
Therefore, the usage by the native sqlite3 library was at least 16MB/
36MB.

Why does it tale so much memory?

P.S. I browsed the sqlite-jdbc code. The while loop boils down to a
single sqlite3_finalize() call.

Original issue reported on code.google.com by taroleo on 3 Jul 2010 at 10:52