Print Thread
Freeing TLOBLocator
#83 10/06/99 11:21 PM
Joined: Oct 1999
Posts: 3
T
Member
OP Offline
Member
T
Joined: Oct 1999
Posts: 3
I have a program with a form that I'm opening and closing several times. I am using a TLOBLocator to read BLOB data and display it in a memo field. I thought that it would be a good idea to free the TLOBLocator upon finishing my reading of the data but when I reentered the form I received an Access Violation the first time that I executed any of the methods for the TOracleQuery Object that the TLOBLocator was referencing. Is it necessary to manually free the TLOBLocator and if so, then how and where?
I've included the procedure where I'm referencing the TLOBLocator.

Thanks,
t.paul

Procedure TfrmDetails.SetDtlQuery(strDocID, strSectID : string);
var
LOB: TLOBLocator;
k: integer;
blobchar: pchar;
begin
qryDtl.Close;
qryDtl.SetVariable('DOCID',strDocID);
qryDtl.SetVariable('SECTID',strSectID);
qryDtl.Execute;
memDetail.Lines.Clear;
while not qryDtl.Eof do begin
LOB := qryDtl.LOBField('xrawdata');
k := LOB.Size;
GetMem(blobchar,k);
LOB.Read(blobchar^,k);
memDetail.Lines.Append(copy(blobchar,1,k));
FreeMem(blobchar);
qryDtl.Next;
end;
// LOB.Free;
frmDetails.showmodal;
end;

Re: Freeing TLOBLocator
#84 10/12/99 10:19 PM
Joined: Aug 1999
Posts: 22,218
Member
Offline
Member
Joined: Aug 1999
Posts: 22,218
You should not free the TLOBLocator instance that is returned by the LOBField function. This is only necessary if you explicitly create one with TLOBLocator.Create. The TOracleQuery owns the LOBLocator and will free it when the next record is fetched or when it is closed. That's why you get the access violation: the TOracleQuery tries to free an instance that is already freed in your code.


------------------
Marco Kalter
Allround Automations


Marco Kalter
Allround Automations

Moderated by  support 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.1.33 Page Time: 0.026s Queries: 13 (0.007s) Memory: 2.4998 MB (Peak: 3.0418 MB) Data Comp: Off Server Time: 2024-05-14 10:33:40 UTC
Valid HTML 5 and Valid CSS