Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / June 2007

Tip: Looking for answers? Try searching our database.

Need explicit OleDbCommand Dispose() for volume queries

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Guy - 13 Jun 2007 19:21 GMT
My application process records...lots of records. I typically read 85K
records from one Ms-Access table, then for each records of that
table , I have to read 3 others tables (in separate Ms-Access DB)
having hundreds of thousands records each, then I insert even more
records in to another table, yet another db.

I recently experienced  an OUT_OF_MEMORY exception from the OleDb
driver. In the task manager, I could see the memory getting chewed
several megs a second. Since I only have one dbReader open at a time,
I was wondering what was causing this memory leak. I found a solution
by experimenting, and it involves calling Dispose() after every use of
all my OleDbCommand objects.

Is this normal ? Is there a better way to do this. Postings are not
cleared as to wether it is necessary to call Dispose explicitely.

Thanks.
Henning Krause [MVP - Exchange] - 13 Jun 2007 20:04 GMT
Hello,

if you don't call Dispose() on an instance of an object, unmanaged memory
will eventually be reclaimed by the garbage collector.

Since the GC collects the objects on a seperate thread, you may receive
OutOfMemory exceptions if the GC cannot reclaim enough memory in a timely
fashion.

As a rule of thumb: If an object implements IDisposable, it does it for a
reason, so call it. Most of the time, it's for disposing unmanaged
resources.

Best regards,
Henning Krause

> My application process records...lots of records. I typically read 85K
> records from one Ms-Access table, then for each records of that
[quoted text clipped - 13 lines]
>
> Thanks.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.