Caves Travel Diving Graphics Mizar Texts Cuisine Lemkov Contact Map RSS Polski
Trybiks' Dive Texts DBExpress Memory Leaks and Connection Explosions in DBExpress YAC Software
  Back

List

Charsets

Charts

DBExpress

Delphi

HTML

Intraweb

MSTest

PHP

Programming

R

Rhino Mocks

Software

Testing

UI Testing

VB.NET

VCL

WPF

Memory Leaks and Connection Explosions in DBExpress
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

Comments
Alas!
No comments yet...

Top

Add a comment (fields with an asterisk are required)
Name / nick *
Mail (will remain hidden) *
Your website
Comment (no tags) *
Enter the text displayed below *
 

Top

Tags

DBExpress

Delphi


Related pages

Delphi interfaces... again

Checking "Dangling" Event Handlers in Delphi Forms

Drag-n-drop files onto the application window

Intraweb and MaxConnections

A Case for FreeAndNIL

Intraweb as an Apache DSO module

"Device not supported" in Intraweb

Automated GUI Testing

Rounding and precision on the 8087 FPU

SessionTimeout in Intraweb

Using TChart with Intraweb

Unknown driver: MySQL

TIdMessage's CharSet

Software Guarantees

Automated Testing of Window Forms

TChart - Missing Labels in Axes

Controlling Conditional Defines and Compilation Switches

Detecting Memory Leaks with DUnit

last_insert_id() and DBExpress

Registering Extensions

DBExpress and Thread Safety

Forms as Frames

Checking Dangling Pointers vs. the New Memory Manager

Accessing Protected Members

Objects, interfaces, and memory management in Delphi