Re: Performance and Memory Usage Consideration about DataTable and Dat
- From: "RobinS" <RobinS@xxxxxxxxxxxxxxx>
- Date: Thu, 22 Mar 2007 22:35:05 -0700
You can't data bind to a DataReader; it only reads one record at a time. It
reads fast, but you have no retainability unless you store the rows
somewhere.
You can convert a datareader into a datatable, but why not just read it as
a DataTable.
Why are you so concerned about the memory taken up by the datatable? Once
it goes out of scope, the GC will know it can be cleared. If it has a
Dispose method, you can invoke it and the GC might dispose of it sooner. I
can't believe an array of the same information would take up a lot less
information. After all a data table is an array of DataRows.
That's my two cents' worth.
Robin S.
-------------------------
"Samuel" <programmer@xxxxxxxxxxxxx> wrote in message
news:73E17D3D-7AD0-4E89-9FA5-8E7EF5C8478D@xxxxxxxxxxxxxxxx
Hi,
How do I free up the memory taken up by the .NET datatable and dataset
after
I finished working with them? How do I HELP the GC to do its job sooner
to
release memory taken up by DataTable/DataSet?
I am worried about memory usage. Should I be using DataReader
exclusively?
But complex databinding is going to cause problem to me because it is
going
to keep the connection open for longer than necessary.
Would it help if I create an arraylist of DbDataRecord from DataReader
instead?
If reader.HasRows Then
For Each rec As System.Data.Common.DbDataRecord In reader
arr.Add(rec)
Next
End If
I am guessing that arraylist takes up less memory than a DataTable. Am I
correct? Or is there a way for me to check how much memory each takes up
(datatable v.s. Arraylist of DbDataRecord)?
Then, how do I use this technique to construct more than one arraylist
when
the datareader returns more than one result set? I can only get the first
resultset and i don't know why. It seems that the reader is closed
automatically when I use this technique.
Another question I have is about DataTable's DataTableReader. What's the
point to use a DataTableReader? Does it make databinding faster than
binding
to Datatable itself? I am sure this would not take less memory so why?
Thanks for any advice you can provide!
.
- Follow-Ups:
- Re: Performance and Memory Usage Consideration about DataTable and
- From: Milosz Skalecki [MCAD]
- Re: Performance and Memory Usage Consideration about DataTable and Dat
- From: William \(Bill\) Vaughn
- Re: Performance and Memory Usage Consideration about DataTable and Dat
- From: Miha Markic [MVP C#]
- Re: Performance and Memory Usage Consideration about DataTable and
- Prev by Date: Re: How to handle concurrency issue with better performance?
- Next by Date: Re: Possible to create an Expression column that reaches back through several relations?
- Previous by thread: Possible to create an Expression column that reaches back through several relations?
- Next by thread: Re: Performance and Memory Usage Consideration about DataTable and Dat
- Index(es):
Relevant Pages
|