public Dictionary<string, IMYObject> MYObjectContainer
{
get
{
if (Session["MYObjectPool"] == null)
Session["MYObjectPool"] = new Dictionary<string,IMYObject>();
return (Dictionary<string, IMYObject>)Session["MYObjectPool"];
}
set
{
Session["MYObjectPool"] = value;
}
}
public ActionResult Close()
{
try
{
MyObject obj = this.MYObjectContainer["Key"]
this.MYObjectContainer = null;
return Json(new { success = true }, JsonRequestBehavior.AllowGet);
}
catch (Exception Ex)
{
throw X
}
}
The garbage collector will delete when the object has no valid referee Here there are two referee,
1.obj (Local variable)
2.Session
First I made the session referee invalid by setting this.MYObjectContainer = null;
Second when the function ends the obj will be popped out of stack thus second referee is invalid
Does this makes the MYObjectContainer
eligible for Garbage Collector to be Cleared ?
Please ignore if my question is totally wrong please advice me ?
How Garbage Collector works in ASP.NET Session ?