Page 1 of 1

Assertion Failed: TOraObject.Free RefCount = 0

Posted: Tue 18 Aug 2015 14:14
by Morelli
Hi Folks,
I use C++ XE6 Builder with ODAC 9.5.18.

The following code looks correct but when I delete the query-Object a EAssertion (EAssertion Failed: TOraObject.Free RefCount = 0 (D:\Projects\Delphi\Dac\Common\Source\MemData.pas, Line 8977)) is rised! Why does a delete rise this Assertion!?
Is there something wrong in my code?

Code: Select all

   TOraSession* session = new TOraSession (0);
   session->Server         = "mapsrv11";
   session->Username       = "hkf14t";
   session->Password       = "hkf14t";
   session->Connected      = true;

   TOraQuery* query = new TOraQuery (0);
   query->Session          = session;

   query->SQL->Clear ();
   query->SQL->Add ((String)
         "select * from geof3044 A where " +
         "mdsys.sdo_relate(A.SHAPE, :CUTPOLY," +
         "'mask=ANYINTERACT querytype=WINDOW') = 'TRUE' or A.geofid = 4796");

   query->Params->Clear();
   query->Params->CreateParam (Db::ftObject, "CUTPOLY", Db::ptInput);

   TOraObject* oraObject = new TOraObject (0);
   oraObject->AllocObject (session->OCISvcCtx, "MDSYS.SDO_GEOMETRY");

      // Create Dummy Object
      //
      oraObject->AttrAsInteger["SDO_GTYPE"] = 2003;
      oraObject->AttrAsObject["SDO_POINT"]->IsNull = true;

      TOraArray* elemInfo = oraObject->AttrAsArray["SDO_ELEM_INFO"];
      elemInfo->ItemAsInteger[0] = 1;
      elemInfo->ItemAsInteger[1] = 1003;
      elemInfo->ItemAsInteger[2] = 1;

      TOraArray* ordinates = oraObject->AttrAsArray["SDO_ORDINATES"];
      ordinates->ItemAsFloat[0] = 1;
      ordinates->ItemAsFloat[0] = 1;
      ordinates->ItemAsFloat[1] = 1;
      ordinates->ItemAsFloat[1] = 2;
      ordinates->ItemAsFloat[2] = 2;
      ordinates->ItemAsFloat[2] = 2;
      ordinates->ItemAsFloat[3] = 2;
      ordinates->ItemAsFloat[3] = 1;

   query->ParamByName ("CUTPOLY")->AsObject = oraObject;
   query->Execute ();

   oraObject->FreeObject (true);

   delete oraObject;
   delete query;     // EAssertion Failed: TOraObject.Free RefCount = 0       (D:\Projects\Delphi\Dac\Common\Source\MemData.pas, Line 8977)
   delete session;
Thanks for your help!
Kind regards
Mike

Re: Assertion Failed: TOraObject.Free RefCount = 0

Posted: Wed 19 Aug 2015 07:57
by AlexP
Hello,

Thank you for the information, we have reproduced the problem and will investigate the reasons for this kind of behaviour. We will inform you as soon as we have any results.

Re: Assertion Failed: TOraObject.Free RefCount = 0

Posted: Fri 28 Aug 2015 08:52
by Morelli
Ok, we are looking forward the results/fixes.

Re: Assertion Failed: TOraObject.Free RefCount = 0

Posted: Fri 28 Aug 2015 09:19
by AlexP
No, this problem has not been fixed, we'll try to fix it in the next version

Re: Assertion Failed: TOraObject.Free RefCount = 0

Posted: Wed 02 Sep 2015 07:34
by AlexP
To solve the problem, you should call oraObject->Release() instead of delete oraObject. In addition, you need not to call the oraObject->FreeObject (true) method.

Re: Assertion Failed: TOraObject.Free RefCount = 0

Posted: Fri 04 Sep 2015 08:20
by Morelli
Ok thx.

So is this usage correct:

We have a class 'AClass' with a member/field

Code: Select all

TOraObject* Geometry
.
This Object is created by calling

Code: Select all

Geometry = new TOraObject (0);
After creating the object we call N Times:

Code: Select all

Geometry->AllocObject (OracleSession->OCISvcCtx, "MDSYS.SDO_GEOMETRY");
//... do something here
Geometry->FreeObject (true);
Then the 'AClass' calls inside the destructor:

Code: Select all

TOraObject->Release () 
to delete the Geometry Object;

Is there a wrong usage or a Memory leak?
Thanks for your help!

Re: Assertion Failed: TOraObject.Free RefCount = 0

Posted: Mon 14 Sep 2015 10:44
by AlexP
As I wrote above, there is no need to call oraObject->FreeObject (true), this won't lead to Memory Leak.


P.S. You can monitor memory leaks by setting the ReportMemoryLeaksOnShutdown global variable to True.