TZReadOnlyQuery memory grow till app crashes
Posted: 24.02.2015, 18:35
Hello All,
I'm a newby with ZeosLIB so it can be I'm not using it as expected but I found the same problem using the official ZSimple.exe example.
Problem is that every time I open the TZReadOnlyQuery to retrive table data, the memory grows up till when the application crashes and it doesn't connect to the DB.
I found a huge of posts info the forum regarding memory problem. Is there a solution?
My application only need to connect and read from a table every 10 minutes.
To help you helping me I'll post the code I'm using:
Thanks in advance to everyone who want to help!
Bye
Claudio
I'm a newby with ZeosLIB so it can be I'm not using it as expected but I found the same problem using the official ZSimple.exe example.
Problem is that every time I open the TZReadOnlyQuery to retrive table data, the memory grows up till when the application crashes and it doesn't connect to the DB.
I found a huge of posts info the forum regarding memory problem. Is there a solution?
My application only need to connect and read from a table every 10 minutes.
To help you helping me I'll post the code I'm using:
Code: Select all
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, StdCtrls, ZConnection, ZDataset, ExtCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
FConnection : TZConnection;
FRaedOnlyQuery : TZReadOnlyQuery;
DataSource : TDataSource;
public
property Connection: TZConnection read FConnection write FConnection;
property Data: TZReadOnlyQuery read FRaedOnlyQuery write FRaedOnlyQuery;
property DS: TDataSource read DataSource write DataSource;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Connection.Protocol := 'oracle';
Connection.Database := edit1.Text;
Connection.User := edit2.Text;
Connection.Password := edit3.Text;
Connection.Connect;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Data.Connection := FConnection;
Data.SQL.Clear;
data.SQL.Add('SELECT * FROM ifc_ctrl');
data.Open;
DS.DataSet := Data;
while not DS.DataSet.Eof do
begin
memo1.Lines.Append(DS.DataSet.FieldByName('Field1').AsString + ' | ' + DS.DataSet.FieldByName('Field2').AsString);
DS.DataSet.Next;
end;
ds.DataSet.Close;
data.Close;
connection.Disconnect;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Connection := TZConnection.Create(Self);
Data := TZReadOnlyQuery.Create(Self);
DS := TDataSource.Create(Self);
end;
Bye
Claudio