UDAC (Oracle) "prepare" Memory leak ?

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Tomomi Umezawa
Posts: 7
Joined: Thu 18 Sep 2008 07:22

UDAC (Oracle) "prepare" Memory leak ?

Post by Tomomi Umezawa » Mon 06 Jun 2016 06:02

Hello. :D

UniDAC in applications using, I received a contact of the memory leak from my customer.
Even here the situation was reproduced.

Recently it has become a hot topic, not related to the TIMESTAMP type.
I might be a component of the setting is wrong.
Please tell me the points to keep in mind.


It was to create a simple test program.
And executed by a timer. Open, Prepare, Close. (Repeated every 3 seconds)
* I want to run the SQL (INSERT). After the Prepare. However, even without performing the INSERT, the memory leak is reproduced.
* To confirm the amount of memory used in the Task Manager.
- Start one minute after, used 38MB.
- When it from for 30 minutes, used 53MB.
- When it from for 50 minutes, used 63MB.

When I use the Direct Mode, the memory leak does not occur.
I've tried also UniQuery1.UnPrepare. But it seems to have a memory leak.


<Test creation>
- To form TUniConnection and the TUniQuery, drop and other related components.
- To the following settings to the components of the property.
- UniQuery1.Connection = UniConnection1
- UniConnection1.ProviderName = Oracle
- Set the following properties of UniConnection1 according to the opponent.
Server, Username, Password, SpecifcOptions.Schema
And set the following events of UniConnection1
OnAfterConnect, OnAfterDisconnect
- Timer1 of the Interval and in 3000, set the OnTimer event


<Environment>
(Server)
Windows 7 Pro + SP1
Oracle: Oracle 11g XE (11.2.0.4)

(Client)
Windows 7 Pro + SP1
Oracle Instant Client (Latest. OCI.dll 2013/10/11)
Delphi 10 Seattle Update 1
UniDAC v6.3.12

Code: Select all

unit uTest_UDAC;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, DBAccess, Uni, MemDS,
  OracleUniProvider, Vcl.StdCtrls, Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
    lblState: TLabel;
    lblPrepareCount: TLabel;
    Timer1: TTimer;
    btnTestStart: TButton;
    btnTestEnd: TButton;
    UniConnection1: TUniConnection;
    UniQuery1: TUniQuery;
    procedure UniConnection1AfterConnect(Sender: TObject);
    procedure UniConnection1AfterDisconnect(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure btnTestStartClick(Sender: TObject);
    procedure btnTestEndClick(Sender: TObject);
  private
    FInitComplete: Boolean;
    FExecCount: Integer;

    FTimerSw: Boolean;

    procedure Init;
    procedure Connect;
    procedure Disconnect;
    procedure Prepare;
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


const
  coSQL =
    'INSERT INTO TESTTBL (' +
      'NAMEID, TESTCOUNT'+
    ') VALUES (' +
      ':F_NameID, :F_TestCount'+
    ');';


procedure TForm1.Init;
begin
  UniQuery1.SQL.Clear;

  UniQuery1.SQL.Text := coSQL;
  FExecCount := 0;
end;


procedure TForm1.Connect;
begin
  UniConnection1.Open;
end;

procedure TForm1.Disconnect;
begin
  UniConnection1.Close;
end;


procedure TForm1.Prepare;
begin
  UniQuery1.Prepare;

  inc(FExecCount);
  lblPrepareCount.Caption := IntToStr(FExecCount);

  //Sleep(100);
  //UniQuery1.UnPrepare;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  if not FInitComplete then begin
    Init;
    FInitComplete := True;
  end;
end;


procedure TForm1.UniConnection1AfterConnect(Sender: TObject);
begin
  lblState.Caption := 'Connect';
end;

procedure TForm1.UniConnection1AfterDisconnect(Sender: TObject);
begin
  lblState.Caption := '---';
end;

procedure TForm1.btnTestStartClick(Sender: TObject);
begin
  Timer1.Enabled := True;
  FTimerSw := True;
end;

procedure TForm1.btnTestEndClick(Sender: TObject);
begin
  Timer1.Enabled := False;
  FTimerSw := False;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Timer1.Enabled := False;
  try
    Connect;
    try
      Sleep(300);
      Prepare;
      Sleep(300);
    finally
      Disconnect;
    end;
  finally
    if FTimerSw then begin
      Timer1.Enabled := True;
    end;
  end;
end;

end.


MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: UDAC (Oracle) "prepare" Memory leak ?

Post by MaximG » Tue 07 Jun 2016 10:41

We have investigated your project behavior. Unfortunately, we couldn't detect memory leaks. For testing, we used FastMM 4 with option FullDebugMode, and MadExcept 4.0.13 with options 'Report resource leaks' and 'Instantly crash on buffer'. Please specify the memory manager you used to detect memory leaks in your environment.

Tomomi Umezawa
Posts: 7
Joined: Thu 18 Sep 2008 07:22

Re: UDAC (Oracle) "prepare" Memory leak ?

Post by Tomomi Umezawa » Thu 09 Jun 2016 06:07

Thank you for the reply.
I'm using the EurekaLog v7.4.
EurekaLog also does not detect the memory leak.
The point is the same as your test.

However, when observing the Processes tab of Task Manager, obviously the memory usage is increasing over time.

My description of the first post might not be appropriate.

In your test environment, when you run the previous post of code, memory usage indicated by the Task Manager to increase ?

It is increasingly passed together with the time, or do not change ?

If possible, the following files, it can be provided via DropBox.
Test source, exe, task manager image file, tnsnames.ora file

P.S.
After I received your reply, I tried to download the madExcept.
madExcept also does not detect the memory leak.
Is the same as your reply.

(I have to create another test program, the operation of madExcept was confirmed.
On purpose to create a program to memory leak. )

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: UDAC (Oracle) "prepare" Memory leak ?

Post by MaximG » Fri 10 Jun 2016 09:19

We are glad you manged to implement a test program demonstrating memory leaks presence on using Oracle TIMESTAMP Type. Send it to maximg*devart*com with including scripts for creating database objects used in the sample.

Tomomi Umezawa
Posts: 7
Joined: Thu 18 Sep 2008 07:22

Re: UDAC (Oracle) "prepare" Memory leak ?

Post by Tomomi Umezawa » Sun 12 Jun 2016 07:10

Thank you for the reply.

I sent you an email.
I wrote a download destination of the test environment.

There is a thing to know one.
This matter has nothing to do with the type TimeStamp.
In the test table does not use the type TimeStamp.

My English is poor.
Misunderstanding there may be.
sorry.

Best Regard.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: UDAC (Oracle) "prepare" Memory leak ?

Post by MaximG » Mon 20 Jun 2016 10:38

We will study the issue and inform you about the results soon

Tomomi Umezawa
Posts: 7
Joined: Thu 18 Sep 2008 07:22

Re: UDAC (Oracle) "prepare" Memory leak ?

Post by Tomomi Umezawa » Mon 20 Jun 2016 12:24

Thank you.

I appreciate cooperation of you.
:D

Best Regards.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: UDAC (Oracle) "prepare" Memory leak ?

Post by MaximG » Thu 23 Jun 2016 08:15

We have investigated your sample. Unfortunately, we couldn't detect a memory leak. Memory consumption increase by this application is seen only in Task Manager. However, the same behavior is observed without using UniDAC. We have composed a simple sample demonstrating a small memory increase at constant freeing of memory:


program Project25;

{$APPTYPE CONSOLE}

uses
SysUtils, math, Forms;

var
p1, p2: pointer;
i, j: integer;
begin
Randomize;
while True do begin
try
i := Random(1000000);
j := Random(1000000);
GetMem(p1, i);
GetMem(p2, j);
finally
FreeMem(p1);
FreeMem(p2);
sleep(500);
end;
end;
end.

After memory allocation, memory increase stops. Please check your sample by removing sleep and longer conducting the experiment .

Tomomi Umezawa
Posts: 7
Joined: Thu 18 Sep 2008 07:22

Re: UDAC (Oracle) "prepare" Memory leak ?

Post by Tomomi Umezawa » Mon 27 Jun 2016 01:39

Hello.
Thank you for the reply.

I want to reply to consider.
However, I had this week is a little busy.
Excuse me. Little reply is slow.
It will be able to reply to the next week. I'm sorry.

Best Regard.

Tomomi Umezawa
Posts: 7
Joined: Thu 18 Sep 2008 07:22

Re: UDAC (Oracle) "prepare" Memory leak ?

Post by Tomomi Umezawa » Wed 03 Aug 2016 05:33

Hello.
It has passed a long time since the last post.
I'm sorry.

I was test your sample.
Memory usage is also certainly this sample (private working set) is increased.

However, I noticed also to be following it.
* Memory usage is sometimes reduced to sudden.
* Commit size is fixed.

The following is a result of long running your me and the sample.
(I bit the source was adjusted. Sorry)

Code: Select all

                Private
  Time         Workingset         Commit Size
 ------------------------------------------------------
  14:27            704K               1848K
  14:47           1152K               1848K
  15:07           1168K               1848K
  15:30           1172K               1848K
  16:24           1052K               1848K
  17:14            884K               1848K
  18:30            840K               1848K
Apparently my previous sample, seems to have been inappropriate to show my suffering to have a problem. I'm sorry.

I have a problem is that if my application using UDAC has been used for a long time the memory usage would continue to increase.

I was that try to attempt to solve the problem from another angle.

So, I tried the Oracle connection components of other maker instead of UDAC.

Sample program is not used.
Actually use the programs that are delivered to the customers.

I tried to change the program.
What it was replaced with another component of the UDAC part.

The results are as follows. (See graph)
https://drive.google.com/file/d/0By4XZJ ... sp=sharing

< use the UDAC >
Commit size will increase to about 600MB from about 40KB of immediately after the start-up.

< use another components >
Although commit size increases even a little after the lapse from 50KB stand for 40 hours or more immediately after start-up, it remains 50KB table.

So I decided to use a different component, In order to solve this problem.

Please do not misunderstand.

I know that the UDAC has been used in many of the user.
Maybe, this problem will be a problem for me on how to use or property, such as setting of UDAC.

But, I have had no time for that pursuit.
So, to avoid the problem that the use of the other components.

Sorry in such a report.
Thank you for your cooperation.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: UDAC (Oracle) "prepare" Memory leak ?

Post by MaximG » Wed 03 Aug 2016 10:31

Thank you for the information. Unfortunately, we couldn't detect a memory leak according to your description. We are ready to investigate this issue in future. Perhaps, in future, you will be able to compose a small full sample, in which memory leaks would definitely appear on using a third-party memory manager.

Tomomi Umezawa
Posts: 7
Joined: Thu 18 Sep 2008 07:22

Re: UDAC (Oracle) "prepare" Memory leak ?

Post by Tomomi Umezawa » Wed 03 Aug 2016 12:25

Thank you for the reply.

There was a mistake to write in front of the e-mail. Correct.
I was wrong to write what places the unit of memory size.

"KB" is incorrect. "MB" is correct.
* 40KB -> 40MB
* 50KB -> 50MB

Sorry.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: UDAC (Oracle) "prepare" Memory leak ?

Post by MaximG » Wed 09 Nov 2016 14:12

Please specify, if you managed to compose a small example, demonstrating the presence of memory leak, when using Unidac with Oracle DB ? In this case, send it, using the contact form https://www.devart.com/company/contactform.html ?

Post Reply