Fix memory leak: ExportStream was recreated for each table in export loop

This commit is contained in:
Ansgar Becker
2012-06-17 11:31:33 +00:00
parent f31867bd5c
commit 59e6e7710d

View File

@ -1149,12 +1149,15 @@ begin
ExportStream := TFileStream.Create(DbDir + DBObj.Name+'.sql', fmCreate or fmOpenWrite); ExportStream := TFileStream.Create(DbDir + DBObj.Name+'.sql', fmCreate or fmOpenWrite);
FHeaderCreated := False; FHeaderCreated := False;
end; end;
if ToFile and (not Assigned(ExportStream)) then if not Assigned(ExportStream) then begin
ExportStream := TFileStream.Create(comboExportOutputTarget.Text, fmCreate or fmOpenWrite); if ToFile then
if ToClipboard and (not Assigned(ExportStream)) then ExportStream := TFileStream.Create(comboExportOutputTarget.Text, fmCreate or fmOpenWrite);
ExportStream := TMemoryStream.Create; // ToDir handled above
if ToDb or ToServer then if ToClipboard then
ExportStream := TMemoryStream.Create; ExportStream := TMemoryStream.Create;
if ToDb or ToServer then
ExportStream := TMemoryStream.Create;
end;
if not FHeaderCreated then begin if not FHeaderCreated then begin
Header := '-- --------------------------------------------------------' + CRLF + Header := '-- --------------------------------------------------------' + CRLF +
Format('-- %-30s%s', ['Host:', DBObj.Connection.Parameters.HostName]) + CRLF + Format('-- %-30s%s', ['Host:', DBObj.Connection.Parameters.HostName]) + CRLF +