How can I check if a memory leak exists the dbexpress components?
In a very simple expample VCL project (1 form, 1 grid, 1 simpledataset) I'm requesting data from a random table from a Micorosft SQL Server using dbexpress Data.DBXMSSQL
. I've enabled memory leak reporting with ReportMemoryLeaksOnShutdown := true;
and as long as only reading data and doing local edits, no memory leaks are reported. If I post changes to the server using
SimpleDataSet1.ApplyUpdates(0);
I get the following message after the program has terminated:
If I enable FastMM4 FullDebugmode, no memory leak is reported. Is there a bug in the memory leak reaporting by delphi 10 or is there a memory leak I have to worry about?
Example unit:
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, Datasnap.DBClient, SimpleDS,
Vcl.Grids, Vcl.DBGrids, Data.SqlExpr, Data.DBXMSSQL;
type
TForm1 = class(TForm)
SQLConnection1: TSQLConnection;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
SimpleDataSet1: TSimpleDataSet;
procedure SimpleDataSet1AfterPost(DataSet: TDataSet);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.SimpleDataSet1AfterPost(DataSet: TDataSet);
begin
SimpleDataSet1.ApplyUpdates(0);
end;
Form definition (simplified):
object Form1: TForm1
object DBGrid1: TDBGrid
DataSource = DataSource1
end
object SQLConnection1: TSQLConnection
ConnectionName = 'XXXXXXXX'
DriverName = 'MSSQL'
LoadParamsOnConnect = True
LoginPrompt = False
Params.Strings = (
'BlobSize=-1'
'DataBase=XXXXXXXX'
'DriverName=MSSQL'
'ErrorResourceFile='
'HostName=XXXXXXXX'
'IsolationLevel=ReadCommitted'
'LocaleCode=0000'
'OS Authentication=False'
'Password=XXXXXXXX'
'Prepare SQL=False'
'SchemaOverride=%.dbo'
'User_Name=XXXXXXXX')
Connected = True
end
object DataSource1: TDataSource
DataSet = SimpleDataSet1
end
object SimpleDataSet1: TSimpleDataSet
Active = True
Aggregates = <>
Connection = SQLConnection1
DataSet.CommandText = 'SELECT * FROM XXXXXXXX'
DataSet.MaxBlobSize = -1
DataSet.Params = <>
Params = <>
AfterPost = SimpleDataSet1AfterPost
end
end
链接地址: http://www.djcxy.com/p/18388.html