在一个非常简单的示例VCL项目(1个表单,1个网格,1个简单数据集)中,我正在使用dbexpress Data.DBXMSSQL
从Micorosft SQL Server的随机表中请求数据。我使用ReportMemoryLeaksOnShutdown := true;
启用了内存泄漏报告,只要只读取数据并进行本地编辑,就不会报告内存泄漏。如果我使用
SimpleDataSet1.ApplyUpdates(0);
程序终止后,我收到以下消息:
如果我启用 FastMM4 FullDebugmode ,则不会报告内存泄漏。在delphi 10的内存泄漏中是否存在漏洞,或者我是否需要担心内存泄漏?
示例单位:
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;
表格定义(简化):
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