我的应用程序使用 Entity Framework 。当我对 Context 执行操作时,例如插入/删除/更新,由于其工作行为的统一性,我确信它会随着这些操作的发生而占用越来越多的内存。
我的问题是:有没有办法获取上下文在给定时刻持有多少内存?
详细信息:
- 没有使用延迟加载
- 不创建代理
- EF 4
最佳答案
当您需要监控应用程序或服务中对象的内存和 CPU 使用情况时,需要 profiler 的同义词.
这里有很多选项。就是找".NET profiler"在谷歌。
请注意,我将您重定向到 Google 以避免垃圾邮件。
回答@Servy 的问题:
Profilers are fine for a debugging tool during development. It's not really something that you can use during the execution of the program outside of development. I get the impression that that's what he's asking about. –
这是执行某种负载测试的要求出现的时候。 OP 应该实现一些模拟真实场景的测试用例,以使统计数据尽可能接近相同代码的实际生产执行。
关于c# - EF 上下文的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27746597/