Thanks Noel. I am sure I don't missing close any connection as well as not 
leave any connection variable which cause the GC not performed.

I am curious why H2 don't close.

I will try netbeans profiler if no good solution. 

在 2013年8月7日星期三UTC+8下午9时27分07秒,liutongxing写道:
>
>
> 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.


Reply via email to