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

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

问题描述

我使用实体框架4.0背后的WCF服务。我的问题是所使用的PROGRAMM内存越来越大了很多(启动200Mo,我在〜1.1Go停止了它。

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.

我如何管理缓存?我的意思是,我有2 DataContext的,其中一人是永远不会用于读取数据,这样我就可以禁用缓存?

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?

感谢您!

推荐答案

首先你不应该<一个href="http://stackoverflow.com/questions/3653009/entity-framework-and-connection-pooling/3653392#3653392">use共享上下文的。每个WCF请求创建新的上下文和处置方面之前,你结束你的运算处理!如果你需要一些数据缓存EF之外做。 EF本身是不应该被用作缓存,没有控制的这种行为。

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.

如果你在IIS托管您服务,您可以通过在程序池的高级设置中指定专用空间限制配置程序池回收。但它只会杀死一切都在那个程序池运行。

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天全站免登陆