从IIS内存清除大型对象 [英] Cleaning up large Objects from IIS Memory

查看:103
本文介绍了从IIS内存清除大型对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个将DataTables存储在内存缓存(AppFabric)中的应用程序.这些数据表可能很大.一旦来自我们的应用程序(MVC站点)的流量很大,IIS的内存使用就会非常迅速地通过屋顶.

I have an application that stores DataTables in an in memory cache (AppFabric). These DataTables can be quite large. Once there is a lot of traffic from our app (MVC site) the memory usage of IIS goes through the roof very quickly.

理想情况下,我们希望能够一旦从Cache请求后释放这些DataTables消耗的内存.

Ideally we want to be able to release the memory that these DataTables consume once requested from the Cache.

Controller的代码类似于

The code of the Controller is something along the lines of

Using (DataTable dt = DataTable)
{
    DataTable dt = Cache.GetObject(objectID);

    //perform some manipulation on Data table
    DataTable dtSmaller = dt.Select("Select top 1...");

   dt.Dispose();
}   
    //return from controller
return dtSmaller;

一旦多次击中该控制器,W3WP.exe进程就会使用大量内存,直到最终耗尽内存.发生的情况是DataTable来自缓存,查询它是为了减少输出数据的大小.然后,我处置原始的DataTable.

Once this controller is hit many times the W3WP.exe process uses masses of memory until eventually going out of memory. What is happening is that a DataTable comes from the Cache, it's queried to reduce the size of the output data. I then dispose the original DataTable.

我一直在寻找一种释放数据表消耗的内存的方法,而不必依赖于IIS垃圾回收

I was looking for a way of releasing the memory consumed by the DataTable without the depending on IIS Garbage Collection

推荐答案

您可以通过调用GC.GetTotalMemory(true)

有关该方法的更多信息:

More info on the method: GC.GetTotalMemory

这篇关于从IIS内存清除大型对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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