What happens to a dataset when your done using it. For example if I create and fill a dataset for a grid, when the user leaves that page or logs out I assume the dataset is still in memory?
Does each user get their own instance of the dataset? In other words, if 2 users hit the same page that uses a grid are they each served their own i开发者_运维问答nstance of the dataset from server memory?
If you do not put it into session or application cache, it will be garbage collected as soon as the page renders.
ASP.NET is stateless, and unless you use session or cache, or have it as a static method, it goes out of scope ASAP.
Example, if you have the following in page load.
DataSet myDataset = new DataSet();
//Do stuff here to fill
dgrMyGrid.DataSource = myDataset;
dgrMyGrid.DataBind();
At the end of this method call, the myDataset would be up for garbage collection.
It is in memory until it is collected. It is collected when the garbage collector starts (due to memory pressure) and it is due for collection. Read up on the garbage colector in the documentation.
I would guess that the garbage collector would reclaim the memory when the application pool recycles is my answer for the first question.
On the second question, it depends on how you set things up. By using the Application object, you could pass the dataset between users, so they could be seeing the same data or you could structure it so each has their own copy of the data.
精彩评论