Thomas,

Should we be creating (opening) and closing a db connection every time
we want to execute a query?

Instead of having a single db entry point maintaining a single
connection... which gets opened and closed on the creation/destroy of
the object?


On Oct 8, 6:04 pm, vsaji <[EMAIL PROTECTED]> wrote:
> Thanks Thomas.
>
> I have identified the issue. I was using a single h2 db connection for
> all requests and after user I didn't close it.
>
> Feeling bit relax now :).
>
> public class H2Test{
>
> private final Connection con = getConnection();
>
> public ResultSet getData(){
> Statement st = con.createStateMent()
> ...............
>
> }
>
> public void update(){
> Statement st = con.createStateMent()
> ...............
>
> }
>
> public void insert(){
> Statement st = con.createStateMent()
> ...............
>
> }
> }
>
> Regards
> Saji
>
> On Oct 9, 3:48 am, "Thomas Mueller" <[EMAIL PROTECTED]>
> wrote:
>
> > Hi,
>
> > From what you describe, it could be a memory leak in the application.
> > Could you post the number without using "grep .h2."
> > But only a reproducible test case would show that.
>
> > Regards,
> > Thomas
>
> > On Wed, Oct 8, 2008 at 12:25 PM, vsaji <[EMAIL PROTECTED]> wrote:
>
> > > Hi Thomas,
>
> > > I could see the same topic has been posted earlier in this forum. I
> > > have tried those resolutions as well. However, no luck.
>
> > > My application is a stand-alone multi threaded application which use
> > > H2 in-memory DB to cache few records.
> > > Currently I am having 7 tables in this database and the avg of record
> > > count is 40 per table.
>
> > > The table gets accessed Max 100 times per second (only SELECT(98%) and
> > > INSERT(2%)). The behavior of the application is, it queries a source
> > > DB on every 5000 ms seconds and transforms the data using the cached
> > > value then stores to a target DB.
>
> > > If you look at the below histo (produced out of JMAP), every interval
> > > the memory consumption is going high and never comes down.
>
> > > I have tried keeping the CACHE_SIZE as 8192 and even tested with
> > > 1.0.79 (last stable version). No changes in the result.
>
> > > PLS HELP.
>
> > > C:\app\jdk1.6.0\bin>jmap -histo 3488 | grep .h2. | head -10
> > >  12:     14793      710064  org.h2.expression.ExpressionColumn
> > >  18:      1755      280800  org.h2.command.dml.Select
> > >  22:     12714      203424  org.h2.util.ObjectArray
> > >  26:      5134      177352  [Lorg.h2.value.Value;
> > >  28:      4833      154656  org.h2.expression.Comparison
> > >  30:      3582      143280  org.h2.expression.ExpressionVisitor
> > >  31:      1755      140400  org.h2.table.TableFilter
> > >  32:      1755      126360  org.h2.result.LocalResult
> > >  34:      2129      119224  org.h2.expression.Function
> > >  35:      4558      117208  [Lorg.h2.expression.Expression;
>
> > > C:\app\jdk1.6.0\bin>jmap -histo 3488 | grep .h2. | head -10
> > >  8:     16058      770784  org.h2.expression.ExpressionColumn
> > >  13:      1813      290080  org.h2.command.dml.Select
> > >  16:     11155      178480  org.h2.util.ObjectArray
> > >  17:      5552      177664  org.h2.expression.Comparison
> > >  20:      1813      145040  org.h2.table.TableFilter
> > >  21:      1858      133776  org.h2.jdbc.JdbcPreparedStatement
> > >  22:      1813      130536  org.h2.result.LocalResult
> > >  24:      3554      103616  [Lorg.h2.expression.Expression;
> > >  25:      1813      101528  org.h2.jdbc.JdbcResultSet
> > >  27:      1657       92792  org.h2.expression.Function
>
> > > C:\app\jdk1.6.0\bin>jmap -histo 3488 | grep .h2. | head -10
> > >  11:     21077     1011696  org.h2.expression.ExpressionColumn
> > >  18:      2447      391520  org.h2.command.dml.Select
> > >  22:     17076      273216  org.h2.util.ObjectArray
> > >  26:      7083      226656  org.h2.expression.Comparison
> > >  28:      2447      195760  org.h2.table.TableFilter
> > >  29:      2447      176184  org.h2.result.LocalResult
> > >  30:      4401      176040  org.h2.expression.ExpressionVisitor
> > >  31:      4842      171440  [Lorg.h2.value.Value;
> > >  33:      2348      169056  org.h2.jdbc.JdbcPreparedStatement
> > >  35:      2843      159208  org.h2.expression.Function
>
> > > C:\app\jdk1.6.0\bin>jmap -histo 3488 | grep .h2. | head -10
> > >  9:     29904     1435392  org.h2.expression.ExpressionColumn
> > >  15:      3362      537920  org.h2.command.dml.Select
> > >  16:     21262      340192  org.h2.util.ObjectArray
> > >  17:     10245      327840  org.h2.expression.Comparison
> > >  19:      3362      268960  org.h2.table.TableFilter
> > >  21:      3362      242064  org.h2.result.LocalResult
> > >  22:      3355      241560  org.h2.jdbc.JdbcPreparedStatement
> > >  26:      7105      200536  [Lorg.h2.expression.Expression;
> > >  28:      3414      191184  org.h2.expression.Function
> > >  29:      3362      188272  org.h2.jdbc.JdbcResultSet
>
> > > C:\app\jdk1.6.0\bin>jmap -histo 3488 | grep .h2. | head -10
> > >  5:     39956     1917888  org.h2.expression.ExpressionColumn
> > >  13:      4452      712320  org.h2.command.dml.Select
> > >  15:     27632      442112  org.h2.util.ObjectArray
> > >  16:     13718      438976  org.h2.expression.Comparison
> > >  17:      4452      356160  org.h2.table.TableFilter
> > >  18:      4460      321120  org.h2.jdbc.JdbcPreparedStatement
> > >  19:      4452      320544  org.h2.result.LocalResult
> > >  21:      9196      262872  [Lorg.h2.expression.Expression;
> > >  24:      4466      250096  org.h2.expression.Function
> > >  25:      4452      249312  org.h2.jdbc.JdbcResultSet
>
> > > C:\app\jdk1.6.0\bin>jmap -histo 3488 | grep .h2. | head -10
> > >  8:     50740     2435520  org.h2.expression.ExpressionColumn
> > >  13:      5708      913280  org.h2.command.dml.Select
> > >  16:     37196      595136  org.h2.util.ObjectArray
> > >  18:     17238      551616  org.h2.expression.Comparison
> > >  22:      5708      456640  org.h2.table.TableFilter
> > >  25:      5708      410976  org.h2.result.LocalResult
> > >  26:      5580      401760  org.h2.jdbc.JdbcPreparedStatement
> > >  28:     12852      352984  [Lorg.h2.expression.Expression;
> > >  29:      6258      350448  org.h2.expression.Function
> > >  32:      5708      319648  org.h2.jdbc.JdbcResultSet
>
> > > C:\app\jdk1.6.0\bin>jmap -histo 3488 | grep .h2. | head -10
> > >  1:     70720     3394560  org.h2.expression.ExpressionColumn
> > >  8:      7796     1247360  org.h2.command.dml.Select
> > >  13:     24344      779008  org.h2.expression.Comparison
> > >  14:     47127      754032  org.h2.util.ObjectArray
> > >  16:      7796      623680  org.h2.table.TableFilter
> > >  17:      7841      564552  org.h2.jdbc.JdbcPreparedStatement
> > >  18:      7796      561312  org.h2.result.LocalResult
> > >  19:     15560      452976  [Lorg.h2.expression.Expression;
> > >  21:      7796      436576  org.h2.jdbc.JdbcResultSet
> > >  22:      7657      428792  org.h2.expression.Function- Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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