I have an Asp.net application hosted on a shared server.
I have few cache objects. One cache object contains around 1 million records with three columns. The rest of the cache objects contain a few hundred records only.
All the records are static. These records are never going to be changed and will be shown in auto complete ajax calls.
I am using Sql Server 2008 for storing data.
If I set the following:
<compilation debug="false" targetFramework="4.0">
The Application is started more occasionally than if i set it to TRUE
My Code:
protected void Application_Start(object sender, EventArgs e)
{
Global.CacheInfo += "Started on" + "----" + DateTime.Now + "<br/>" + Environment.NewLine; ;
RegisterRoutes(RouteTable.Routes);
RouteTable.Routes.RouteExistingFiles = true;
using (BEntity context = new BEntity())
{
// Adding Items to Cache
BLSuggestion.GetAllTitle();
BLSuggestion.GetAllSubCategories();
}
PerformanceCounter pc = new PerformanceCounter("ASP.NET Applications", "Cache % Machine Memory Limit Used", "__TOTAL__", true);
Global.CacheInfo += string.Format("{0:0.00}%", pc.NextValue());
}
This value comes to be around 95% if the application is started. Later a few more cache objects are created. But even then the Application is restarted after about 1 minute.
Any help with this would be much appreciated.
IIS automatically restarts the application when certain (user defined) CPU/memory thresholds are reached. Since you are storing lots of info in memory I guess that you have reached this threshold and IIS simply takes down the AppDomain as instructed in the configuration to prevent your application eating lots of memory. This is often done by shared hosting providers. So you could ask your provider what are those limits that your application is configured to run under.