I am using the embedded mode for H2.
I initialized the H2 with the code
JdbcDataSource h2DataSource = new JdbcDataSource();
h2DataSource.setUser("sa");
h2DataSource.setPassword("");
h2DataSource.setURL("jdbc:h2:mem:aaa;DB_CLOSE_DELAY=-1");
As you can see, I set the DB_CLOSE_DELAY as -1 so that it won't close when
the connection is closed and I can share the DB to other thread.
And closed it using
Connection conn = h2DataSource.getConnection();
Statement statement = conn.createStatement();
statement.execute("SET DB_CLOSE_DELAY 0");
statement.execute("shutdown");
In the closing code, I set the DB_CLOSE_DELAY* *to 0 as your feature page
described as below:
"The value 0 is the default and means the database is closed when
the last connection is closed."
And I shutdown it to ensure it is closed.
But the problem is that this solution doesn't work!!!
The h2 db still resident in the memory after the close action as shown in
the bottom.
My questions are
- how to close the h2 in embedded mode. I find someone unregister driver
to close it but I don't think it is a good practice and I still not tried
with it yet.
- why h2 occupy so much memory (more than 9GB) as I just deal with 4
million record and it is only 354MB after exported through CSV.
Really appreciate for your answer.
<https://lh4.googleusercontent.com/-kVRCmP3WOvM/UgJIithDs3I/AAAAAAAABFE/MjvnZfp5AzQ/s1600/VisualVM+1.3.3_002.png>
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.