I have the following method which presents IIS worker requests on a pretty webpage however every time the page is refreshed it increases the memory consumption of dllhost (COM Surrogate) on the target machine until there is no more memory available. I'm a beginner when it comes to C# so I'm hoping somebody can explain to me how I can change this code to release the memory footprint on the target server each time its refreshed?
protected void Page_Load(object sender, EventArgs e)
{
manager = ServerManager.OpenRemote("Lonappu01032");
int filtered = Convert.ToInt32(Request.QueryString["filter"]);
StringBuilder sb = new StringBuilder();
foreach (WorkerProcess proc in manager.WorkerProcesses)
{
RequestCollection rc = proc.GetRequests(0);
var selected = from r in rc
select r;
if (filtered>0)
{
selected = from r in rc
where r.SiteId == filtered
select r;
}
foreach (Request r in selected)
{
sb.AppendFormat("<tr><td><a href=\"?filter={8}\">{8}</a></td><td>{0}</td><td>{1}</td><td>{2}</td><td><img src=\"http://mobilust.net/onlines/iptoflag.aspx?ip={3}\" alt=\"{3}\" /> {3}</td><td>{4} ({5}s)</td><td>{6}</td><td>{7}</td></tr>", r.HostName, Server.HtmlEncode(r.Url), r.Verb, r.ClientIPAddr, r.PipelineState, TimeSpan.FromMilliseconds(r.TimeInState).TotalSeconds, r.CurrentModule, TimeSpan.FromMilliseconds(r.TimeElapsed).TotalSeconds, r.SiteId);
RequestCount++;
}
}
}
Total <%=manager.WorkerProcesses.Count%> Worker Processes, <%=RequestCount %> requests