I use zeosdbo with Postgresql 7.3. and Delphi.
I use CreateBlobStream.
Memory Leak happend.
exp)
BlobStream := CreateBlobStream(TBlobField(Fields[1]), bmRead);
BlobStream.Free;
--------------
I found problem.
-- ZDbcPostgreSqlResultSet.pas
within:procedure TZPostgreSQLBlob.ReadBlob;
ReadStrem is not released.
725: SetStream(ReadStream);
I added this code.
if ReadStream <> Nil then
ReadStream.Free;
end;
Postgresql BlobRead Memory Leak
Moderators: gto, cipto_kh, EgonHugeist
Sorry.
TZPostgreSQLBlob.ReadBlob is
ReadStream was Created, But is not Free.
Will I be wrong?
TZPostgreSQLBlob.ReadBlob is
Code: Select all
procedure TZPostgreSQLBlob.ReadBlob;
var
BlobHandle: Integer;
Buffer: array[0..1024] of Char;
ReadNum: Integer;
ReadStream: TMemoryStream;
begin
if not Updated and (FBlobOid > 0) then
begin
BlobHandle := FPlainDriver.OpenLargeObject(FHandle, FBlobOid, INV_READ);
CheckPostgreSQLError(nil, FPlainDriver, FHandle, lcOther, 'Read Large Object',nil);
if BlobHandle >= 0 then
begin
ReadStream := TMemoryStream.Create;
repeat
ReadNum := FPlainDriver.ReadLargeObject(FHandle, BlobHandle,
Buffer, 1024);
if ReadNum > 0 then
begin
ReadStream.SetSize(ReadStream.Size + ReadNum);
ReadStream.Write(Buffer, ReadNum);
end;
until ReadNum < 1024;
FPlainDriver.CloseLargeObject(FHandle, BlobHandle);
ReadStream.Position := 0;
end else
ReadStream := nil;
SetStream(ReadStream);
if ReadStream <> Nil then
ReadStream.Free;
end;
end;
Will I be wrong?
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Hi,
Thanks for reporting again, in the bug tracker this time.
I did apply the patch now. (in the easy version as you wrote it above, not an exact copy from the bug tracker)
Cipto, FreeAndNil is not necessary as the variable is only local and destroyed a few lines later at the end of the procedure.
Mark
Thanks for reporting again, in the bug tracker this time.
I did apply the patch now. (in the easy version as you wrote it above, not an exact copy from the bug tracker)
Cipto, FreeAndNil is not necessary as the variable is only local and destroyed a few lines later at the end of the procedure.
Mark