实体框架:缓存管理? [英] Entity Framework: Cache management?

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

问题描述

我正在使用WCF服务后面的Entity Framework 4.0。我的问题是,程序使用的内存正在增长很多(开始à200Mo,我在〜1.1Go停止了。



如何管理缓存?我的意思是说,我有两个datacontext,其中一个从来不用于读取数据,所以可以禁用缓存?



另外,我可以指定有空间可以使用吗?有没有办法监控这些资源?有没有办法使用较少的资源?



谢谢!

解决方案

首先你不应该使用共享上下文为每个WCF请求创建新的上下文,并在结束操作处理之前处理上下文!如果您需要一些数据缓存,请在EF外部执行,EF本身不应该是用作缓存,并且无法控制此行为。



如果您在IIS中托管服务,您可以通过spe配置AppPool回收在AppPool的高级设置中选择私人内存限制。但是它只会杀死那个AppPool中的所有内容。


I'm using Entity Framework 4.0 behind WCF services. My problem is that the memory used by the programm is growing a lot(start à 200Mo, and I stopped it at ~1.1Go.

How can I manage the cache? I mean, I've two datacontext, one of them is never used to read data, so can I disable the cache?

And for the other, can I specify the amount of space it cans use? Is there a way to monitor these resources? Is there a way to use less resources?

Thank you!

解决方案

First of all you should not use shared contexts. Create new context for each WCF request and dispose context before you end your operation processing! If you need some data caching do it outside of EF. EF itself is not supposed to be used as cache and there is no control of this behavior.

If you host your service in IIS you can configure AppPool recycling by specifying Private Memory Limit in advanced settings of the AppPool. But it will simply kill everything running in that AppPool.

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

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