开发者

Entity Framework - _objectTypeCount after disposing

In my website I've a ObjectContextStorage which keeps all the ObjectContext in them. After the http-request is done I throw away this storage (remove it from HttpContext.Current.Items) and dispose the ObjectContexts in this storage.

Now when I debug开发者_运维百科 and look at the _objectTypeCount of my ObjectContext it keeps raising when I reload my website while I would think the old ObjectContext is disposed??

Why is the old ObjectContext still in my memory after disposing it?


You are watching a static variable of the ObjectContext class:

private static int _objectTypeCount; // Bid counter
internal readonly int ObjectID = System.Threading.Interlocked.Increment(
                                                       ref _objectTypeCount);

I've no clue what's the purpose of this. (It counts how often an ObjectContext has been created during an application or session lifetime, or something ???)

But because it's static you cannot conclude from an ever increasing counter that your ObjectContext instances haven't been removed from memory.

Edit

This counter and the ObjectID in the code apparently has to to with so called BID tracing. "BID" stands for "Built-In-Diagnostics". The internal code construct above occurs in many ADO.NET classes. It is used just for tracing method calls in those classes and occurs in trace functions like this:

EntityBid.Trace("<ec.EntityCommandDefinition.CreateCommand|ADV> %d#\n",ObjectID);

The _objectTypeCount and the ObjectID are just there to give an instance of a type a name (or unique ID) for tracing output.

Aside from tracing it has no functional meaning inside of the ObjectContext class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜