This is a migrated thread and some comments may be shown as answers.

Open Access Still Alive after dispose

1 Answer 56 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jonah
Top achievements
Rank 1
Jonah asked on 02 Apr 2015, 02:57 PM
I am been trying to track down memory issues with my WPF project. When running just trace, open access has many instances that have been disposed that are still alive. I am wondering if I am doing something wrong? I have my datacontext in a using statement and assumed that it would clean up when finished.

1 Answer, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 07 Apr 2015, 11:53 AM
OpenAccess has to deal with several types of information:
(a) meta information (class structure, field descriptions, table and columns, ...)
(b) states (instances where the persistent content is stored)
(c) user visible instances of enhanced, persistence-capable types.

Meta information is bound to open database instances. Once you have opened a database (fired a query against the database for the first time), this meta information is fixed and won't increase in size. In order to dispose that, you will need to dispose/close the database. (see http://docs.telerik.com/data-access/feature-reference/api/context-api/feature-ref-api-context-api-dispose )

All states are bound to the life time of the context. Once you have disposed the context, those GenericState instance will be gone too.

User visible instances (from enhanced, user defined classes) are also managed by the OpenAccessContext instances, but can have additionally arbitrary cycles between them. Once the managing context is disposed, those user controlled cycles are left alone and nothing is forced to be in memory any longer. Normally, OpenAccess uses only weak references from the managing context to the user instances to permit GC to happen, and only in cases of modified instances there will be additional hard references.

My best guess is that there is a static field somewhere through which those instances from (c) are held. 
Or are those instances that JustTrace shows as alive of type (a) like ClassMetaData, FieldMetaData, RelationalTable...?

Regards,
Thomas
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
Tags
Development (API, general questions)
Asked by
Jonah
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Share this question
or