Re: Performance and Memory Usage Consideration about DataTable and Dat




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!


.



Relevant Pages

  • Re: Performance and Memory Usage Consideration about DataTable and
    ... Yes, you can bind controls to datareader, ... Have in mind DataReader is used internally in DbDataAdapter.Fill method ... How do I free up the memory taken up by the .NET datatable and dataset ... Another question I have is about DataTable's DataTableReader. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Performance and Memory Usage Consideration about DataTable and Dat
    ... How do I free up the memory taken up by the .NET datatable and dataset after ... Would it help if I create an arraylist of DbDataRecord from DataReader ... automatically when I use this technique. ... Another question I have is about DataTable's DataTableReader. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Performance and Memory Usage Consideration about DataTable and Dat
    ... array. ... You can't data bind to a DataReader; it only reads one record at a time. ... How do I free up the memory taken up by the .NET datatable and dataset ... Another question I have is about DataTable's DataTableReader. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: How to read OleDbSchemaGuid tables 1 record at a time ?
    ... Patrice ha scritto: ... .NET is doing under the hood and try to reproduce uisng a datareader. ... I never said I am holding all the tables in memory. ... GetOledbSchema ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: How to read OleDbSchemaGuid tables 1 record at a time ?
    ... Patrice ha scritto: ... .NET is doing under the hood and try to reproduce uisng a datareader. ... I never said I am holding all the tables in memory. ... GetOledbSchema ...
    (microsoft.public.dotnet.framework.adonet)