473,395 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Would the DataSet be released by the Garbage Collector?

Would this DataSet be cleaned up?

void Main()
{
DataSet ds = null;

//Imagine this returns some tables
ReturnData(out ds);

//Grab a handle to the first row in the Configuration Table.
DataRow dr = ds.Tables["Configuration"].Rows[0];

//Create a new class and give the refence to the DataRow
TestClass t = new TestClass(dr);
}

Since a refence to part of the original DataSet exists, would this
prevent the DataSet being colelcted by the Garbage collector?

I know I could extract the fields from the Row, into another container,
but the DataRow really is the object I need to use.

Thanks for the help in advance.

Steven


*** Sent via Developersdex http://www.developersdex.com ***
Jan 23 '07 #1
5 1529
hi Steven,

Steven Blair wrote:
Would this DataSet be cleaned up?
Yes, if ReturnData() is side-effect free. All your other
objects/references are local to your Main() methode.
mfG
--stefan <--
Jan 23 '07 #2
What I mean though, if TestClass kicked of Threads and control was no
returned to the main (the application is a service).

Would the DataSet be collected at at some point during the lifetime of
the service, or would the DataSet remain in memory because my TestClass
still has a reference back to the DataSet.

*** Sent via Developersdex http://www.developersdex.com ***
Jan 23 '07 #3
Hi,

Well, DataRow itself has a reference to it's DataTable, which has a
reference to it's DataSet. So even though the local variables are out of
scope, the GC can't collect the DataSet since "live" objects still reference
it.

--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in VS IDE)

"Stefan Hoffmann" <st*************@explido.dewrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
hi Steven,

Steven Blair wrote:
>Would this DataSet be cleaned up?
Yes, if ReturnData() is side-effect free. All your other
objects/references are local to your Main() methode.
mfG
--stefan <--

Jan 23 '07 #4
Hi,

Keeping a reference to the DataRow will prevent the GC from collecting the
DataSet since it's still "in use".

--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in VS IDE)

"Steven Blair" <st**********@btinternet.comwrote in message
news:eI**************@TK2MSFTNGP02.phx.gbl...
What I mean though, if TestClass kicked of Threads and control was no
returned to the main (the application is a service).

Would the DataSet be collected at at some point during the lifetime of
the service, or would the DataSet remain in memory because my TestClass
still has a reference back to the DataSet.

*** Sent via Developersdex http://www.developersdex.com ***

Jan 23 '07 #5
Dave,

Thanks, that what I thought.
I might have to take a copy of the DataRow or hold the information in a
different way.

*** Sent via Developersdex http://www.developersdex.com ***
Jan 24 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Anthony Baxter | last post by:
On behalf of the Python development team and the Python community, I'm happy to announce the release of Python 2.3.3 (release candidate 1). Python 2.3.3 is a bug-fix release of Python 2.3. A...
0
by: Anthony Baxter | last post by:
On behalf of the Python development team and the Python community, I'm happy to announce the release of Python 2.3.3 (final). Python 2.3.3 is a bug-fix release of Python 2.3. A couple of serious...
1
by: Bob | last post by:
Are there any known applications out there used to test the performance of the .NET garbage collector over a long period of time? Basically I need an application that creates objects, uses them, and...
10
by: pachanga | last post by:
The Hans-Boehm garbage collector can be successfully used with C and C++, but not yet a standard for C++.. Is there talks about Garbage Collector to become in the C++ standard?
6
by: Eric | last post by:
for example: SqlConnection is used in my project, how can I know if all connections were closed after open and execution. If some guys forget to close connections after using, how can i check it...
5
by: LBT | last post by:
I have a window service written in VB.NET to scan directory and process file. During directory scanning (scheduled by timer using System.IO.Directory.GetFiles method), I can observe that the column...
13
by: Mingnan G. | last post by:
Hello everyone. I have written a garbage collector for standard C++ application. It has following main features. 1) Deterministic Finalization Providing deterministic finalization, the system...
142
by: jacob navia | last post by:
Abstract -------- Garbage collection is a method of managing memory by using a "collector" library. Periodically, or triggered by an allocation request, the collector looks for unused memory...
8
by: Paul.Lee.1971 | last post by:
Hi everyone, A program that I'm helping to code seems to slow down drastically during initialisation, and looking at the profiling graph, it seems to be the garbage collector thats slowing things...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.