我只是想知道这一天。我不完全确定ASPX如何管理垃圾处理,但据我所知,“完成的加载”不会删除静态内存值或页面重新加载后。至少就C而言,静态意味着在程序本身关闭之前,内存分配跟随你的程序。这在ASPX中是一样的吗?如果我有一个静态值,并且从页面A转到页面B,那么静态值在内存中仍然保留,直到他们离开应用程序,或者当我不再处于页面A时,该值会被删除? (转到另一个网站,将其实例从服务器中的应用程序池中除去)。ASP.NET中的静态对象会浪费内存吗?
从我所经历的:
public static class foo
{
public static int x;
}
protected void Page_Load(object sender, EventArgs e)
{
foo.x++; //This will continue to increment from the last value before reload
}
http://stackoverflow.com/questions/1714064 –
http://stackoverflow.com/questions/1563171 –
http://stackoverflow.com/questions/3814608 –