ODAC 6.25 memory consumption

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: 10
Joined: Thu 08 Nov 2007 14:41

ODAC 6.25 memory consumption

Post by [email protected] » Mon 19 Nov 2007 13:33

I have a viewer to read and display spatial data from Oracle Locator 10g. Simple sql like "select * from table" with 160 000 records was executing quite long but with low memory consumption (about 25MB). New ODAC 6.25 on the same code run much faster but eats lots of memory (460MB) and after the query finish and closes, it doesn't release the memory (only after application terminate). Settings for query object are:

oOraDynaset.FetchAll := False;
oOraDynaset.ReadOnly := True;
oOraDynaset.UniDirectional := true;

oOraDynaset.Options.CacheLobs := false;
oOraDynaset.Options.ScrollableCursor := false;
oOraDynaset.Options.StrictUpdate := False ;

What has changed that causes such problems? In the history file there is said that SELECT and blobs has been optimized. I tested query options and it appears that ScrollableCursor work changed. In old version settings True\False caused memory increasing/stable amount behaviour. The latest ODAC vesion doesn't behave like that. The memory raises all the time.

Maybe it's related with http://crlab.com/forums/viewtopic.php?t=10784 but SDO_GEOMETRY is an object type not blob. Nevertheless the memory symptoms are the same.

Any help how to prevent memory allocation on client cursor site?

[email protected]
Posts: 10
Joined: Thu 08 Nov 2007 14:41

Post by [email protected] » Mon 19 Nov 2007 15:59

I see that OraClasses and OraObject has been changed. Now new object is not being allocated each record ( that's nice ) but accessing SDO_GEOMETRY elements that also are objects causes new allocations that are not freed. IF I try to manipulate the object like in Geometry demo to receive vector data, new allocations consumes lots of memory.

[email protected]
Posts: 10
Joined: Thu 08 Nov 2007 14:41

Post by [email protected] » Mon 19 Nov 2007 21:52

Hi

I tested few things and found out that in OraClasses, line 9990 :

OraObject.AllocObject(FConnection.GetSvcCtx); // ??? Optim?

should not be commented like in previous version. I suppose it’s a mistake because such line is not commented for dtArray, which is also an object type. When I uncommented this line, all things referred below seem to work fine. UniDirectional and ScrollableCursor properties behave like before. But I encountered AV errors like “AV in module orageneric10.dll. Write of address xxxx” in function TOCICommand.InternalFetchPiece8

Res := OCIStmtFetch(FCursorRef.OCIStmt, hOCIError, 1, OCI_FETCH_NEXT, OCI_DEFAULT) // line 7388

when OraDynaset.Options.ScrollableCursor := True;

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 20 Nov 2007 09:42

We have fixed the problem that memory is not freed on closing the query. The fix will be included in the next build of ODAC.
If you have ODAC with sources, you can fix the problem by adding the line in OraClasses.pas:

Code: Select all

          OraObject.NativeInstance := True;
after the line:

Code: Select all

          //OraObject.AllocObject(FConnection.GetSvcCtx); // ??? Optim?
You should leave commented the line with AllocObject call.

You should also add public property NativeInstance to TOraObject class in OraObjects.pas:

Code: Select all

    property NativeInstance: boolean read FNativeInstance write FNativeInstance;

[email protected]
Posts: 10
Joined: Thu 08 Nov 2007 14:41

Post by [email protected] » Tue 20 Nov 2007 10:31

Thanks for fast response. It helped and works great now, good work. I have one more technical question. InitBlock procedure creates object instance for a field that is an object type, that's ok, but why it is done for each fetched row? The columns and field definition remain the same. I just worry about doing the same operations may times.

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Wed 21 Nov 2007 09:45

TOraObject instance holds a value of object field for particular record. So TOraObject instances are created for each record.

Post Reply