If you're using Delphi 2007 (as I am since I don't have time to move to Unicode Delphi 2009 now)
you might be experiencing memory leaks and/or connection explosions when using DBExpress with MySQL.
The first problem surfaces when connections have AutoClone and KeepConnection set to TRUE -
ExecuteDirect clones connections but doesn't free them afterwards.
The second problem appears when a single connection is used to run ExecuteDirect statements and select queries.
Connections aren't being dropped and the connection limit is quickly used up.
Probably there are more scenarios where these problems occur,
but at least I can reproduce both problems using approaches mentioned above.
Fortunately, in D2009 there's an updated SqlExpr.pas unit.
By running a diff on the unit's D2007 and D2009 versions, you can find new code added in D2009:
if (Connection <> nil) and Connection.FIsCloned then
Connection.Free;
The above code was added around lines 2685 in D2007 and 2773 in D2009,
in the finally block of the try statement in function TSQLConnection.ExecuteDirect.
The nice thing is, this change fixes both problems mentioned at the start of this post. :-)
HTH
Top
|