TOraType.Free error during disconnect session

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
[email protected]
Posts: 27
Joined: Fri 12 Feb 2010 07:44

TOraType.Free error during disconnect session

Post by [email protected] » Mon 28 Feb 2011 11:21

Hello.

I use ODAC for inserting spatial data to oracle database:

TOraType *OraType = new TOraType( q->Session->OCISvcCtx,"MDSYS.SDO_GEOMETRY");
TOraObject *OraObject = new TOraObject( OraType );

Next I fill all required parameters:

OraObject->AttrAsInteger["SDO_GTYPE"] = .....
OraObject->AttrAsInteger["SDO_SRID"] = .....

and coordinates:
OraObject->AttrAsObject["SDO_POINT"]->AttrAsFloat["X"] = ......
OraObject->AttrAsObject["SDO_POINT"]->AttrAsFloat["Y"] = ......

I send to database:
q->SQL->Clear();
q->SQL->Add( );
q->ParamByName()->AsObject = OraObject;

After sending data to database I release memory in that way:

q->ParamByName()->AsObject->FreeObject( true );
OraObject->FreeObject( true );
delete OraType;

Everyting works fine, I mean data are properly inserted to database.
Problem is during disconnect session:
sSession->Disconnect();
I receive error:
"TOraType.Free RefCount = 0 (D:\Projects\Delphi\Dac\Common\Source\MemData.pas, line 7856)"
and session is still connected.

I tryed to cach it and it's ok, but when I close the application I receive that error again and appliaction is crashing with Access violation.

I suppose, no, I'm sure :-) that problem is because I release memory in that way. If I remove that line of code no errors appears. Am I doing something wrong with that? I have to free that memory because I insert a lot of objects.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 28 Feb 2011 13:09

Hello,

To resolve the problem you should use the Release() or the Free() methods instead of calling the destructor (delete) directly.

[email protected]
Posts: 27
Joined: Fri 12 Feb 2010 07:44

Post by [email protected] » Mon 28 Feb 2011 15:27

It works. Thanks a lot :-)

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 28 Feb 2011 15:36

Hello,

It is good to see that this problem was solved. If any other questions come up, please contact us.

Post Reply