mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-14 01:56:36 +08:00
Free data sets before loading new data.
Seems there are still per-query memory leaks to be found.
This commit is contained in:
32
childwin.pas
32
childwin.pas
@ -457,7 +457,6 @@ type
|
|||||||
WhereFilters : TStringList;
|
WhereFilters : TStringList;
|
||||||
WhereFiltersIndex : Integer;
|
WhereFiltersIndex : Integer;
|
||||||
StopOnErrors, WordWrap : Boolean;
|
StopOnErrors, WordWrap : Boolean;
|
||||||
FCurDataset : TDataSet;
|
|
||||||
FMysqlConn : TMysqlConn;
|
FMysqlConn : TMysqlConn;
|
||||||
FConn : TOpenConnProf;
|
FConn : TOpenConnProf;
|
||||||
QueryRunningInterlock : Integer;
|
QueryRunningInterlock : Integer;
|
||||||
@ -470,7 +469,7 @@ type
|
|||||||
function GetActiveGrid: TSMDBGrid;
|
function GetActiveGrid: TSMDBGrid;
|
||||||
procedure WaitForQueryCompletion(WaitForm: TForm);
|
procedure WaitForQueryCompletion(WaitForm: TForm);
|
||||||
function RunThreadedQuery(AQuery : String) : TMysqlQuery;
|
function RunThreadedQuery(AQuery : String) : TMysqlQuery;
|
||||||
procedure DisplayRowCountStats;
|
procedure DisplayRowCountStats(ds: TDataSet);
|
||||||
|
|
||||||
public
|
public
|
||||||
ActualDatabase : String;
|
ActualDatabase : String;
|
||||||
@ -1282,6 +1281,7 @@ var
|
|||||||
manualLimit : boolean;
|
manualLimit : boolean;
|
||||||
manualLimitEnd : integer;
|
manualLimitEnd : integer;
|
||||||
DisplayedColumnsList : TStringList;
|
DisplayedColumnsList : TStringList;
|
||||||
|
tmp : TDataSet;
|
||||||
begin
|
begin
|
||||||
viewingdata := true;
|
viewingdata := true;
|
||||||
try
|
try
|
||||||
@ -1445,11 +1445,6 @@ begin
|
|||||||
|
|
||||||
MainForm.ShowStatus( 'Retrieving data...', 2, true );
|
MainForm.ShowStatus( 'Retrieving data...', 2, true );
|
||||||
|
|
||||||
if ( FCurDataset <> nil ) then
|
|
||||||
begin
|
|
||||||
FreeAndNil( FCurDataset );
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Read columns to display from registry
|
// Read columns to display from registry
|
||||||
with( TRegistry.Create ) do
|
with( TRegistry.Create ) do
|
||||||
begin
|
begin
|
||||||
@ -1513,11 +1508,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// free previous resultset
|
// free previous resultset
|
||||||
try
|
tmp := DataSource1.DataSet;
|
||||||
DataSource1.DataSet.Free;
|
DataSource1.DataSet := nil;
|
||||||
DataSource1.DataSet := nil;
|
FreeAndNil(tmp);
|
||||||
except
|
|
||||||
end;
|
|
||||||
|
|
||||||
// start query (with wait dialog)
|
// start query (with wait dialog)
|
||||||
SynMemoFilter.Color := clWindow;
|
SynMemoFilter.Color := clWindow;
|
||||||
@ -1533,7 +1526,6 @@ begin
|
|||||||
MainForm.ShowStatus( 'Filling grid with record-data...', 2, true );
|
MainForm.ShowStatus( 'Filling grid with record-data...', 2, true );
|
||||||
mq.MysqlDataset.DisableControls();
|
mq.MysqlDataset.DisableControls();
|
||||||
DataSource1.DataSet := mq.MysqlDataset;
|
DataSource1.DataSet := mq.MysqlDataset;
|
||||||
FCurDataset := mq.MysqlDataset;
|
|
||||||
|
|
||||||
// Attach After- and Before-Events to the new dataset
|
// Attach After- and Before-Events to the new dataset
|
||||||
with ( mq.MysqlDataset ) do
|
with ( mq.MysqlDataset ) do
|
||||||
@ -1604,7 +1596,7 @@ begin
|
|||||||
// for letting NULLs being inserted into "NOT NULL" fields
|
// for letting NULLs being inserted into "NOT NULL" fields
|
||||||
// in mysql5+, the server rejects inserts with NULLs in NOT NULL-fields,
|
// in mysql5+, the server rejects inserts with NULLs in NOT NULL-fields,
|
||||||
// so the Required-check on client-side is not needed at any time
|
// so the Required-check on client-side is not needed at any time
|
||||||
FCurDataset.Fields[j].Required := false;
|
mq.MysqlDataset.Fields[j].Required := false;
|
||||||
|
|
||||||
// set column-width
|
// set column-width
|
||||||
if (
|
if (
|
||||||
@ -1626,7 +1618,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
DisplayRowCountStats();
|
DisplayRowCountStats(mq.MysqlDataset);
|
||||||
dataselected := true;
|
dataselected := true;
|
||||||
viewingdata := false;
|
viewingdata := false;
|
||||||
mq.MysqlDataset.EnableControls();
|
mq.MysqlDataset.EnableControls();
|
||||||
@ -1645,7 +1637,7 @@ end;
|
|||||||
Calculate + display total rowcount and found rows matching to filter
|
Calculate + display total rowcount and found rows matching to filter
|
||||||
in data-tab
|
in data-tab
|
||||||
}
|
}
|
||||||
procedure TMDIChild.DisplayRowCountStats;
|
procedure TMDIChild.DisplayRowCountStats(ds: TDataSet);
|
||||||
var
|
var
|
||||||
rows_matching : Int64; // rows matching to where-filter
|
rows_matching : Int64; // rows matching to where-filter
|
||||||
rows_total : Int64; // total rowcount
|
rows_total : Int64; // total rowcount
|
||||||
@ -1713,7 +1705,7 @@ begin
|
|||||||
) then
|
) then
|
||||||
begin
|
begin
|
||||||
Panel5.Caption := Panel5.Caption + ', limited to ' +
|
Panel5.Caption := Panel5.Caption + ', limited to ' +
|
||||||
FormatNumber( FCurDataset.RecordCount );
|
FormatNumber( ds.RecordCount );
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2615,8 +2607,10 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Unlink ZQuery1 from db-controls, relink them when query was successful
|
// Destroy old data set.
|
||||||
|
ds := DataSource2.DataSet;
|
||||||
DataSource2.DataSet := nil;
|
DataSource2.DataSet := nil;
|
||||||
|
FreeAndNil(ds);
|
||||||
// set db-aware-component's properties..
|
// set db-aware-component's properties..
|
||||||
DBMemo1.DataField := '';
|
DBMemo1.DataField := '';
|
||||||
DBMemo1.DataSource := DataSource2;
|
DBMemo1.DataSource := DataSource2;
|
||||||
@ -4631,7 +4625,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// Display row count and filter-matchings above dbgrid
|
// Display row count and filter-matchings above dbgrid
|
||||||
DisplayRowCountStats;
|
DisplayRowCountStats(DataSet);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMDIChild.ZQueryGridBeforeClose(DataSet: TDataSet);
|
procedure TMDIChild.ZQueryGridBeforeClose(DataSet: TDataSet);
|
||||||
|
Reference in New Issue
Block a user