Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

ADOExpress memory leak

The following code initially takes 1876 Kb of memory. The first time the timer executes the mem usage goes up to 2812 Kb, but doesn't go back down when the ADO objects are destroyed. It remains pretty constant on further executions of the timer event, occasionally growing by 4-5 kb (this is not consistent, but appears to happen on every 5 executions on average). This is a major issue because in my app there are several ADO objects created resulting in a memory useage jump by almost 7 Mb on the first execution. Does anyone have any idea what this leak is, and more importantly how to get rid of it ?

Kevin

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, ADODB;

type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Timer1Timer(Sender: TObject);
var
oADOConn : TADOConnection;
oADOQuery : TADOQuery;
begin
oADOConn := TADOConnection.Create( nil );
oADOQuery := TADOQuery.Create( nil );
FreeAndNil( oADOConn );
FreeAndNil( oADOQuery );
end;

end.

Comments

  • rezashahranrezashahran Member Posts: 21
    : The following code initially takes 1876 Kb of memory. The first time the timer executes the mem usage goes up to 2812 Kb, but doesn't go back down when the ADO objects are destroyed. It remains pretty constant on further executions of the timer event, occasionally growing by 4-5 kb (this is not consistent, but appears to happen on every 5 executions on average). This is a major issue because in my app there are several ADO objects created resulting in a memory useage jump by almost 7 Mb on the first execution. Does anyone have any idea what this leak is, and more importantly how to get rid of it ?
    : procedure TForm1.Timer1Timer(Sender: TObject);
    : var
    : oADOConn : TADOConnection;
    : oADOQuery : TADOQuery;
    : begin
    : oADOConn := TADOConnection.Create( nil );
    : oADOQuery := TADOQuery.Create( nil );
    : FreeAndNil( oADOConn );
    : FreeAndNil( oADOQuery );
    : end;

    Maybe, ur server doing some task on Query, and it dosnot free until the task is down, try to disconnect the query first then destroy the object, or be sure about the finishing the query and then use Destroy.
    Reza

  • CSSKevinCSSKevin Member Posts: 8
    : : The following code initially takes 1876 Kb of memory. The first time the timer executes the mem usage goes up to 2812 Kb, but doesn't go back down when the ADO objects are destroyed. It remains pretty constant on further executions of the timer event, occasionally growing by 4-5 kb (this is not consistent, but appears to happen on every 5 executions on average). This is a major issue because in my app there are several ADO objects created resulting in a memory useage jump by almost 7 Mb on the first execution. Does anyone have any idea what this leak is, and more importantly how to get rid of it ?
    : : procedure TForm1.Timer1Timer(Sender: TObject);
    : : var
    : : oADOConn : TADOConnection;
    : : oADOQuery : TADOQuery;
    : : begin
    : : oADOConn := TADOConnection.Create( nil );
    : : oADOQuery := TADOQuery.Create( nil );
    : : FreeAndNil( oADOConn );
    : : FreeAndNil( oADOQuery );
    : : end;
    :
    : Maybe, ur server doing some task on Query, and it dosnot free until the task is down, try to disconnect the query first then destroy the object, or be sure about the finishing the query and then use Destroy.
    : Reza
    :

    The connection and query objects are not opened in this sample. Simply creating and destroying the objects is enough to cause the leak

    :

  • Justin BibJustin Bib USAMember Posts: 0

    _____ || http://forcoder.org || free ebooks and video tutorials about // Python Scratch Go Visual Basic C PL/SQL Perl Objective-C Visual Basic .NET C# R C++ Assembly JavaScript Delphi MATLAB Ruby Swift PHP Java SAS Erlang F# LabVIEW FoxPro Lisp Fortran Awk Hack Logo Kotlin Clojure ABAP Rust Lua VBScript Julia Scala Dart Prolog Bash Transact-SQL Apex Alice Crystal Scheme COBOL D Ada ML // ______

Sign In or Register to comment.