Subject Memory Out Of Control
Author masseyis2
Hi,

I have an application that has been using firebird for persistence
quite happily during development so far. Because my app deals with
money, I decided I need to transaction the money operations. To do
this the quickest way I could, I have setup a system that wraps round
Connection and Statement to store all the update statements and
perform them together at the point when my connection is returned to
the pool. This way, the connection can be passed around between
methods that are part of a transaction. So for example, the following
might happen:

deposit(){
MyConnection con = dbPool.getconnection()
Statement stmt = con.createStatement()

stmt.executeUpdate("UPDATE members SET
balance=balance"+depositAmount+"); <-- This will just store this SQL
in an arrayList

logDeosit(con) <-- will just perform and insert
reduceMyAccount(con) <-- will perform an inline update

dbPool.releaseConnection(con) <-- at this point the statements are
actually performed
}


So when the connection is released, it tries to perform all the
updates. If they deadlock, it rolls back and then tries again, 5 times.

Because my app only reads from the DB at startup, this is safe, since
it never performs a write based on data from a read. And this way I
could be sure all transactions are grouped together.

Now, the problem is (finally!) that since putting this in, the amount
of Memory firebird uses is now spiralling quite fast. What used to be
100Mb total memory after 12 hours is now 2Gb in five minutes!!

I'm am pretty sure that all Statements and ResultSets get closed and
all Transaction are committed, because this is done by the
ConnectionPool. The isolation level is READ_COMMITTED, as anything
stronger deadlocks unnecessarily. And Autocommit is false, of course.

Can anyone give me any clues as to why this is making my fbserver
footprint so large? Incidentally, it is highly concurrent. Many
threads will be performing these transactions at the same time, though
rarely on the same data.

Any help would be greately appreciated.

Thanks

Masseyis(2)