Hi,

I can't reproduce the problem. According to my test case, the memory
consumption stays at below 32 MB (as I would have expected) when using
the default settings.

To understand what the problem is, I would need more information. What
version of H2 do you use? What is the database URL, and what are the
settings (specially the cache size)? Do you use in-memory tables? You
could run your test using

java -XX:+HeapDumpOnOutOfMemoryError

and then analyze the heap dump using EclipseMAT. Or you could use

jps -l
jmap -histo <pid>

to get a heap histogram.

> we are working with really big H2 Database >2-3 gb.

My test case creates a 3 GB database.

> "SCRIPT TO ...." with compression and AES encryption

I use script to '~/temp/test.dat' compression deflate cipher aes password 'test'

My test case: http://h2database.com/p.html#e015ca1dbf2013b59ac3cd35eecccee3

Regards,
Thomas

---------------

package db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.util.Random;
import org.h2.tools.DeleteDbFiles;
import org.h2.util.IOUtils;
import org.h2.util.Utils;

public class TestSimpleDb {

    public static void main(String... args) throws Exception {
        // run with:
        // java -XX:+HeapDumpOnOutOfMemoryError
        // and analyze the heap dump using Eclipse MAT

        Class.forName("org.h2.Driver");
        String url = "jdbc:h2:~/temp/test";

        // init database
        DeleteDbFiles.execute("~/temp", "test", true);
        Connection conn;
        conn = DriverManager.getConnection(url);
        Statement stat;
        stat = conn.createStatement();
        stat.execute("set log 0");
        stat.execute("set undo_log 0");
        stat.execute("create table test(id identity, " +
                "data binary, empty varchar default space(1000))");
        PreparedStatement prep = conn.prepareStatement(
                "insert into test(data) values(?)");
        Random r = new Random(1);
        byte[] buff = new byte[2000];
        for (int i = 0;; i++) {
            long len = IOUtils.length("~/temp/test.h2.db");
            if (len > 3000L * 1024 * 1024) {
                break;
            }
            System.out.println("rows: " + i * 10000 +
                    " size: " + (len / 1024 / 1024) + " MB");
            for (int j = 0; j < 10000; j++) {
                r.nextBytes(buff);
                prep.setBytes(1, buff);
                prep.execute();
            }
        }
        conn.close();

        // backup
        conn = DriverManager.getConnection(url);
        stat = conn.createStatement();
        Thread t = new Thread() {
            public void run() {
                while (true) {
                    System.out.println("memory: " +
                            (Utils.getMemoryUsed() / 1024) + " MB");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        // ignore
                    }
                }
            }
        };
        t.setDaemon(true);
        t.start();
        stat.execute("script to '~/temp/test.dat' " +
                "compression deflate cipher aes password 'test'");
    }

}

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to