Memory leak with CLOB field (Delphi XE, ODAC 8.2)

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
balazs miereisz
Posts: 22
Joined: Wed 06 May 2009 14:28

Memory leak with CLOB field (Delphi XE, ODAC 8.2)

Post by balazs miereisz » Tue 03 Jul 2012 10:55

Hi Team,

We use FastMM4 unit to explore the memory leaks in our application. After we upgrade to the latest ODAC (8.2) package we are experiencing some memory leaks. With ODAC 8.1 we haven't got this problem.

This is how we can produce some memory leaks with CLOB field:

Oracle code:

Code: Select all

CREATE TABLE T_CLOBTEST (
  ID NUMBER(9) PRIMARY KEY,
  CLOBDATA CLOB
);

INSERT INTO T_CLOBTEST(ID) VALUES (1);

COMMIT;
Delphi XE code draft:

OraQuery1.SQL:

SELECT ID, CLOBDATA
FROM T_CLOBTEST
WHERE ID = :iID

OraQuery1.SQLInsert:

INSERT INTO T_CLOBTEST (ID, CLOBDATA)
VALUES (:ID, EMPTY_CLOB())
RETURNING CLOBDATA INTO :CLOBDATA

Code: Select all

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, DB, DBAccess, Ora, MemDS;

type
  TForm1 = class(TForm)
    OraQuery1: TOraQuery;
    OraSession1: TOraSession;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses FastMM4;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  OraQuery1.Close;
  OraQuery1.ParamByName('iID').AsInteger := 1;
  OraQuery1.Open;

  OraQuery1.Close;
  OraQuery1.ParamByName('iID').AsInteger := -1;
  OraQuery1.Open;

  OraQuery1.Append;
  OraQuery1.FieldByName('ID').AsInteger := 2;
  OraQuery1.FieldByName('CLOBDATA').AsString := 'TEST';
  OraQuery1.Post;
  OraQuery1.Close;
end;

end.
After pressing Button1 and closing the sample application FastMM reports some memory leaks in objects TCompressedBlobData and TOraLob.

Best regards,
Balazs Miereisz

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Memory leak with CLOB field (Delphi XE, ODAC 8.2)

Post by AlexP » Thu 05 Jul 2012 11:35

hello,

We could reproduce this problem only on a "clean" FastMM, when the FullDebugMode option is enabled, no memory leak is detected. As well as it is not detected when using the EurekaLog utility. We will investigate this problem and let you know the results.

a-s-z
Posts: 106
Joined: Wed 03 Dec 2008 06:01

Re: Memory leak with CLOB field (Delphi XE, ODAC 8.2)

Post by a-s-z » Thu 07 Feb 2013 11:32

Hi,
AlexP wrote:hello,

We could reproduce this problem only on a "clean" FastMM, when the FullDebugMode option is enabled, no memory leak is detected. As well as it is not detected when using the EurekaLog utility. We will investigate this problem and let you know the results.
We have this problem too and are using Odac 8.6.11.

After reading this post and topic http://forums.devart.com/viewtopic.php? ... 04&p=83576, I have checked the implementation of FastMM4.
FastMM will fill memory blocks with a predefined pattern in FullDebugMode, so the problem of uninitialized/reused items will not appear with standard FastMM. If you change FastMM4.DebugFillByte to $DD, problem will be visible in FullDebugMode too. CatchUseOfFreedInterfaces must be disabled for this to work.

Best Regards,
Andre

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Memory leak with CLOB field (Delphi XE, ODAC 8.2)

Post by AlexP » Mon 11 Feb 2013 12:20

Hello,

We have fixed the problem. The new version with this fix will be released this week.

Post Reply