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.
Ideally we want to be able to release the memory that these DataTables consume once requested from the Cache.
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;
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.
I was looking for a way of releasing the memory consumed by the DataTable without the depending on IIS Garbage Collection