?
Solved

Question about datatable objects and releasing resources for same

Posted on 2011-04-27
2
Medium Priority
?
209 Views
Last Modified: 2012-05-11
I have a database helper class that returns a datatable to the calling method. In that database helper class function, I open the connection, load the newly declared datatable, close the connection and then return the table.

My question is what keeps this from causing problems with creating a new datatable each time this is called. Couldn't I possibly run out of resources if done hundreds or thousands of times?

If I set the datatable to nothing in the calling method when I'm finished does that take care of releasing the resources created in the database helper class?
0
Comment
Question by:rutledgj
2 Comments
 
LVL 18

Accepted Solution

by:
lludden earned 1000 total points
ID: 35478290
When an object is no longer referenced, it is marked for cleanup by the garbage collection process.  This happens automatically in a separate thread.  You can force the garbage collection to run with GC.Collect()

0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35481939
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month16 days, 5 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question