DataReaders & Memory

  • Thread starter Thread starter Jon Brunson
  • Start date Start date
J

Jon Brunson

Darren pointed out to me that I should be careful with DataReaders as
they eat memory. I always thought that they were a low-memory Class, and
the best way to get data out of a database, is this not the case? Would
a DataTable take up less memory than a reader?
 
Jon,

No, a DataReader is going to be more efficient than a DataAdapter
filling a table. Where you get into trouble (especially with SQL CE 2.0)
is that if you leave a trail of open data readers in your code, you will
quickly overwhelm the SQL CE engine and consume both managed and
unmanaged memory in the process. There is also a memory leak in the
original
managed provider for SQL CE 2.0 that enters the equation with CF1.

Just close and dispose of SqlCeDataReaders ASAP and you will be fine.

Also investigate the use of SqlCeResultSet if you are using SQL Mobile and
CF2.

Newsgroup for all of these topics is microsoft.public.sqlserver.ce or the
MSDN Forum at
http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=152&SiteID=1

--
Darren Shaffer
..NET Compact Framework MVP
Principal Architect
Connected Innovation
www.connectedinnovation.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top