Home > Back-end >  Used zeosdbo, my program memory has been up after each reading list
Used zeosdbo, my program memory has been up after each reading list

Time:01-07

Delphi7 and delphi10.2.3 are tried, zeosdbo - 7.2.4 - stable and zeosdbo 7.2.8 - stable are also tried

The unit Unit1;

Interface

USES the
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Activex,
Dialogs, StdCtrls ZAbstractConnection, ZConnection ZAbstractRODataset, ZAbstractDataset, ZDataset;


Type
TForm1=class (TForm)
For: TButton;
Procedure Button1Click (Sender: TObject);
Procedure FormCreate (Sender: TObject);
Procedure FormDestroy (Sender: TObject);
Private
{Private declarations}
Procedure TestFunc;
Public
{Public declarations}
end;

Var
Form1: TForm1;
SQry: TZQuery;//TZQuery
ADOC: TZConnection;
Implementation

{$R *. DFM}

Procedure TForm1. Button1Click (Sender: TObject);
Var
I: Integer;
The begin
For I:=0 to 1000 do
TestFunc;
end;

Procedure TForm1. TestFunc;
The begin
Try
Try
ADOC. LoginPrompt:=False;
ADOC. Connected:=False;

ADOC. The HostName:='192.168.3.50';
ADOC. Port:=3306;
ADOC. Database:='HZST';
ADOC. User:='root';
ADOC. Password:='28000066';
ADOC. Protocol:='mysql - 5';
GBK ADOC. ClientCodepage:=' ';
ADOC. Connected:=True;

SQry. Close;
SQry. SQL. Text:='select * from Usertable';
SQry. Open;

OutputDebugString (PChar (sQry FieldByName (" username "). AsString) are identical);

//
Except,

end;
The finally
SQry. Close;
ADOC. Connected:=False;
end;
end;

Procedure TForm1. FormCreate (Sender: TObject);
The begin
Coinitialize (nil);
ADOC:=TZConnection. Create (nil);
ADOC. LoginPrompt:=False;
SQry:=TZQuery. Create (nil);
SQry. Connection:=ADOC;
ADOC. Connected:=False;
end;

Procedure TForm1. FormDestroy (Sender: TObject);
The begin
SQry. Free;
SQry:=nil;

ADOC. Free;
ADOC:=Nil;
CoUninitialize;
end;

end.

CodePudding user response:

Used before, but haven't tested memory growth problems

Not recommended zeosdbo,,,,


Use FireDAC, connection pool model, a variety of database support, I used to high mysql, postgresql,, super handy

https://blog.csdn.net/jhzhao2001/article/details/79059062

CodePudding user response:

No, what are the advantages?

CodePudding user response:

FormCreate add
ReportMemoryLeaksOnShutdown:=True;
Run off, see hint where,

CodePudding user response:

Used from your code, every time is closed data set, could it be he did some cache itself,
  • Related