Does the linq enumerator stream? (memory bloat problem)
Posted: Mon 01 Nov 2010 14:41
Hi,
I was wondering if the devart linq enumerator streams (I am using the MySql one). For example, when I do:
does the full MyTable get loaded into memory before iteration starts? Or does only one row at a time get loaded into memory as I print them out.
The reason I am asking is because I am trying to iterate over a large table and it looks like I have a huge memory spike in the foreach statement, which is highly undesirable. It would be much better to load one row at a time, as I would expect with an enumerator. If I called ToList() on the query, then it would be acceptable to form an in memory list of everything, but not until then.
I was wondering if the devart linq enumerator streams (I am using the MySql one). For example, when I do:
Code: Select all
foreach (var item in from mt in DataContext.MyTable select mt)
{
Console.Out.WriteLine(item);
}
The reason I am asking is because I am trying to iterate over a large table and it looks like I have a huge memory spike in the foreach statement, which is highly undesirable. It would be much better to load one row at a time, as I would expect with an enumerator. If I called ToList() on the query, then it would be acceptable to form an in memory list of everything, but not until then.