Subject Re: [Firebird-Java] Memory Leek with Statement Pooling
Author Roman Rokytskyy
Hi,

> If i create a report with many different statements used memory is
> growing. (Thats normal i thing, because the statements are cached)
> After creating the report the connection is given back to the pool.
> Memory is not given back.

Correct. If I'm not wrong, this fix was added as you suggested to keep
statements open even after connection.close(), because otherwise performance
improvement is not so big.

> And this happens every time i create the same report, so i think the
> statement are not used again the the cache is growing and growing.

When connection is released back to pool it is added to the end of the queue
(e.g. we have LRU policy for connection caching). When you ask for a new
connection, you get connection where no statements were prepared. In your
case your memory will grow until all connections are used at least once (min
is 5, max is 30).

> If i setStatementPooling(false) and comment out the 4 lines after it
> the memory is not growing, not for the first time i create the
> report and not for creation after that.

More or less correct. You release statement each time you close it.

> I hope this can be fixed and is not a normal effect for statement
> pooling, because i think the pooling really makes my application
> faster.

We need to add a pooling policy (LRU vs MRU). This is not 5 min. hack, I
will add it to my todo list for 1.6. If I get time to fix it in 1.5.x, I
will add it there too.

Roman