实体框架TypeUsage对象 [英] Entity Framework TypeUsage Object

查看:174
本文介绍了实体框架TypeUsage对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行在我的应用程序内存分析器找到一个可能的内存泄漏。 System.Data.Metadata.Edm.TypeUsage对象的数量越来越一致,它看起来像这可能是我的内存问题的原因。

I am running a memory profiler on my application to find a possible memory leak. The number of System.Data.Metadata.Edm.TypeUsage objects is consistently growing and it looks like this may be cause of my memory issues.

有谁知道从内存中释放这些TypeUsatge对象的方法吗?他们看起来是内部实体框架对象,因为我没有在我的代码给他们任何引用。我已经证实了我所包裹用块中的背景对象,内存被释放,但这种用法并不想离开。

Does anyone know a way of releasing these TypeUsatge objects from memory? They look to be internal Entity Framework objects since I do not have any reference to them in my code. I have confirmed that I have wrapped the context object within a using block, and the memory is being released, but this Type usage doesn't want to go away.

任何帮助您可以提供将不胜感激。

Any help you can provide would be greatly appreciated.

推荐答案

您可能正在在第1级高速缓存(更改追踪)的实体框架使用的下面。要了解更多关于它检查了这一点。我会感到惊讶,如果有内存泄漏在这里,更有可能的是,这只是正常的行为。你看到泄漏多少内存?

You are probably looking at the 1st-level cache (Change Tracker) that Entity Framework uses underneath. To read more about it check this out. I'd be surprised if there is a memory leak here, more likely that this is just normal behaviour. How much memory do you see leaking?

要释放内存,请尝试使用其他合并选项(如NoTracking)。默认值是AppendOnly,这将举行在内存类型,你可能会再次使用。 NoTracking合并选项会去到数据库的每个时间和保持什么在内存中。

To release the memory, try using another merge option (like NoTracking). The default is AppendOnly, which will hold on to types in memory that you might use again. NoTracking merge option will go to the database every time and hold nothing in memory.

希望这有助于。

这篇关于实体框架TypeUsage对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆