Article

From:
To:
Charles Jensen
Subject:
Re: IBQuery memory leak
Newsgroup:
embarcadero.public.delphi.database.interbase_express

Re: IBQuery memory leak

Charles Jensen wrote:
> I'm having a problem with memory leaks after updating (several) projects from XE2 to XE3.
> 
> Clearly visible when ReportMemoryLeaksOnShutdown is enabled. => It seems to be related to using TIBQuery. 
> 
> Could it be because memory is allocated with GetMem/ReAllocMem (in IBAlloc) and freed by "FreeRecordBuffer" by setting the pointer to nil?
> 
> - Charles

Yes that is a leak.  change it to

procedure TIBCustomDataSet.FreeRecordBuffer(var Buffer: TRecordBuffer); begin    if Assigned(Buffer) then      ReallocMem(Buffer, 0); end;
and statically link IBCustomDataset.pas to your app (Might need IBQuery.pas too).

For most of XE3's beta TRecordBuffer at the db.pas level was defined as 
Array<byte> so was allocated with SetLength and deallocated with setting it to 
nil.  Very late in the beta it was switched back to a pointer and this line was 
missed (Actually someone on the dev team switched it back for me and I just 
verified changes, this didn't change cause they missed it so I didn't catch it 
either, still my fault).

-- Jeff Overcash (TeamB)        (Please do not email me directly unless asked. Thank You) And so I patrol in the valley of the shadow of the tricolor I must fear evil. For I am but mortal and mortals can only die. Asking questions, pleading answers from the nameless faceless watchers that stalk the carpeted corridors of Whitehall.               (Fish)
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack
Fri, 30 Jul 2021 23:56:20 UTC
Copyright © 2009-2021
HREF Tools Corp.