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);
FHeaderCreated := False;
end;
if ToFile and (not Assigned(ExportStream)) then
ExportStream := TFileStream.Create(comboExportOutputTarget.Text, fmCreate or fmOpenWrite);
if ToClipboard and (not Assigned(ExportStream)) then
ExportStream := TMemoryStream.Create;
if ToDb or ToServer then
ExportStream := TMemoryStream.Create;
if not Assigned(ExportStream) then begin
if ToFile then
ExportStream := TFileStream.Create(comboExportOutputTarget.Text, fmCreate or fmOpenWrite);
// ToDir handled above
if ToClipboard then
ExportStream := TMemoryStream.Create;
if ToDb or ToServer then
ExportStream := TMemoryStream.Create;
end;
if not FHeaderCreated then begin
Header := '-- --------------------------------------------------------' + CRLF +
Format('-- %-30s%s', ['Host:', DBObj.Connection.Parameters.HostName]) + CRLF +