
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.