Datasets use a lot of memory and are designed for functionality and
reuse of database datatypes -not simple byte structures. If you create data
and throw it away you should not use a Dataset - use a DataReader to a
collection of objects.
Also try not to add lots of single items to a dataset row by row. Add
all the rows at once. DataTable.Merge(DataRow) etc ;
The internal represention can result in a lot of extra memory.Dont be
fooled by row collection (Rows) into thinking a Dataset is a simple Array
they do a much more complex function. If you are just storing bytes think
about the internal objects that need to be build eg DataSet , Rows
collection , DataTables , DataRows , Collums , DataView(default views) Item
Array , XMLBoundElement and many more etc . All these objects take a lot of
memory but make working with Datasets easy. You will also find that if you
use a more realistic representation eg 50 Unicode character first name ,
last name , address then the over head is not as high.
Anyway the internal representation is quite complex.
Quote:> I forgot to mention that adding to the dataset also took much more time
> adding to the array...
I'm using a dataset to store some byte values. I've created a dataset with
10 columns, each one representing a byte.
I then added a few thousand rows to the dataset using a for loop.
To compare, I did the same thing, but this time using a 2 dimensional byte
To my surprise, the dataset took more than 5 times memory than the array !
(I'm talking about megabytes !!).
Why does the dataset take up so much memory ? Is there any way to tweak the
dataset so it will take less ?
I'd be glad if someone could supply the answers to these questions.