Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi Prism/Database/DBX for ADO.NET support    [ Add a report in this area ]  
Report #:  92593   Status: Open
DbxInterbaseDriver leaks statements on server after DbCommand disposed
Project:  Embarcadero Prism Build #:  4.0.25.791
Version:    1.1 Submitted By:   Bruce Horn
Report Type:  Crash / Data loss / Total failure Date Reported:  3/25/2011 10:26:45 AM
Severity:    Critical / Show Stopper Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   282407
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
Disposing a DbCommand with this driver doesn't appear to have any effect on the server. The result is that each SQL statement run on a connection is a memory leak, until the connection is closed.


Added by Sysop
<<<<<<<<<<<<<<<
We have to call 'conn.Close();' or 'conn.Dispose();' to free DbCommand resources.
However, in case of server application, we generally do not close/dispose connections!!
Please see comments of QC for more information.
>>>>>>>>>>>>>>>
Steps to Reproduce:
1. Create a connection from DbProviderFactories.GetFactory("Borland.Data.DbxInterBaseDriver");
2. Create a DbCommand from it: cmd := conn.CreateCommand()
3. Execute the command
4. Dispose the command
5. Debug the code and step to a point immediately after the Dispose
5. Check in IBConsole Performance Monitor -> Statements that the statement has been freed.

Sample code snippet attached which creates and disposes 1000 commands


The Borland.Data.* DLLs used are all 15.00.3953.35171.

Server tested was Interbase 2007
Workarounds
None
Attachment
92593.zip
Comments

Tomohiro Takahashi at 3/27/2011 6:42:17 PM -
In your C# code, you forget to call 'conn.Close();' or 'conn.Dispose();'.
Could you please try to call conn.Close(); or conn.Dispose(); ?

However, in case of server application, we generally do not close/dispose connections...


Anyway, this is better code with Prism language for a simple standalone application.
========================
method MainForm.button1_Click(sender: System.Object; e: System.EventArgs);
begin
  var prov := System.Data.Common.DbProviderFactories.GetFactory('Borland.Data.DbxInterBaseDriver');
  using conn := prov.CreateConnection() do begin
    conn.ConnectionString := 'database=192.168.10.1/3050:C:\InterBase2007\test.db;user_name=SYSDBA;password=masterkey';
    conn.Open();  
    var i := 0;
    while i < 1000 do begin
      using cmd := conn.CreateCommand() do begin
        cmd.CommandText := 'select count(*) from TESTTBL;';
        System.Diagnostics.Debug.WriteLine('count: {0}', cmd.ExecuteScalar());
      end;
      inc(i);
    end;
  end;
  System.Diagnostics.Debug.WriteLine('Check IB console Performance Monitor->Statements now!');
end;
========================

[machine.config]
========================
<DbProviderFactories>
<add name="Interbase AdoDbx Data Provider" invariant="Borland.Data.DbxInterBaseDriver" description=".Net Framework Data Provider for InterBase dbExpress Driver" type="Borland.Data.TAdoDbxInterBaseProviderFactory, Borland.Data.DbxInterBaseDriver, Version=15.0.0.0, Culture=neutral, PublicKeyToken=91d62ebb5b0d1b1b" />
</DbProviderFactories>
========================

Bruce Horn at 3/28/2011 3:29:10 AM -
Correct, this would be run on a server so no immediate conn.Close() or Dispose().

If the loop in the sample is made infinite, then eventually (~16,500 iterations on my server) the connection dies with:

Borland.Data.TAdoDbxException (0x00000065): Unable to complete network request to host "ib2007server".
Error reading data from the connection.
   at Borland.Data.TAdoDbxProviderFactory.AdoDbxException(TDBXError DBXError)
   at Borland.Data.TDBXContext.Error(Int32 ErrorCode, String ErrorMessage)
   at Borland.Data.TDBXMethodTable.RaiseError(TDBXContext DBXContext, Int32 DBXResult, IntPtr DBXHandle, String AdditionalInfo)
   at Borland.Data.TDBXDynalinkCommand.CheckResult(Int32 DBXResult)
   at Borland.Data.TDBXDynalinkCommand.DerivedPrepare()
   at Borland.Data.TDBXCommand.Prepare()
   at Borland.Data.TDBXMorphicCommand.Prepare()
   at Borland.Data.TAdoDbxCommand.InitDbxCommand()
   at Borland.Data.TAdoDbxCommand.ExecuteDbDataReader(CommandBehavior Behavior)
   at Borland.Data.TAdoDbxCommand.ExecuteScalar()
   at MyDbxTest.Form1.button1_Click(Object sender, EventArgs e)

Tomohiro Takahashi at 3/28/2011 6:16:35 PM -
Ok, if you need quick help, please contact technical support service or sales rep of Embarcadero. Sorry for inconvenience.
http://support.embarcadero.com/

Server Response from: ETNACODE01