Saturday, March 28, 2009

SQLDataReader and DataSet

In terms of memory, We always say that we should avoid use of DataSet unless it is very much required. If the requirement can be accomplished with SQLDataReader never use DataSet.

The common answer which we know is DataSet takes more memory than SQLDataReader.

I thought why not find out how much more memory DataSet consumes than SQLDataReader. I ran CLR profiler and I found significant difference between two.

DataSet take 60% more memory than SQLDataReader.

I just created object of SQLDataReader( SqlDataReader dr = new SqlDataReader();), the memory consumption is 22,218 bytes.

And when I created objet of DataSet (DataSet ds = new DataSet();) , the memory consumption is 35,920 bytes.


Use DataSet carefully :)

Happy Coding :)


No comments:

Site Meter