In my .net application, I have used LINQ-to-SQL to get some data from the database. The volume of data is not big at all (10 rows of data). But I constantly caught the "system.outofmemoryException" in my function even thought there is still spare memory in the server. Interestingly, I can still get the data with a ADO function from other pages.
The problem will be fixed once application pool restarts. From time to time, issue happen again. Do you have any clue how I should debug this scenario?
Note: I have used "using" block for all datacontext connection. Literally, All datacontext would be disposed after use.
Below is the code. It is simple.
using (StoreDataContext db = new StoreDataContext(conn))
{
var list = from category in db.ProductCategories
select category;
ddlCategory.DataSource = list.Distinct().ToList();
ddlCategory.DataTextField = "CategoryName";
ddlCategory.DataValueField = "CategoryName";
ddlCategory.DataBind();
}
Distinct? It implies that you're not selecting from master table.