473,513 Members | 2,576 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get rid of DataTable

How can get rid of a DataTable instance?

Set it to null + call Dispose on it? Anything else? Is Dispose really
necessary given that the DataTable doesn't hold any resources (AFAIKT)?

Yes, I know there is no deterministic finalization - but I want to do my
best to tell the system that I'm done with the DataTable ... and the garbage
collector is free to have it's way with it.

Thanks.

Jun 27 '08 #1
7 3324
On May 29, 11:38*am, "Jordan S." <A...@B.comwrote:
How can get rid of a DataTable instance?

Set it to null + call Dispose on it? *Anything else? Is Dispose really
necessary given that the DataTable doesn't hold any resources (AFAIKT)?

Yes, I know there is no deterministic finalization - but I want to do my
best to tell the system that I'm done with the DataTable ... and the garbage
collector is free to have it's way with it.

Thanks.
Hi,

You can call Dispose if it implement it, and you can set it to null.
this will free the memory IF (and that's a capital if) it's not
referenced somewhere else,like for example in a DataSet
Jun 27 '08 #2
On May 29, 12:03*pm, "Ignacio Machin ( .NET/ C# MVP )"
<ignacio.mac...@gmail.comwrote:
On May 29, 11:38*am, "Jordan S." <A...@B.comwrote:
How can get rid of a DataTable instance?
Set it to null + call Dispose on it? *Anything else? Is Dispose really
necessary given that the DataTable doesn't hold any resources (AFAIKT)?
Yes, I know there is no deterministic finalization - but I want to do my
best to tell the system that I'm done with the DataTable ... and the garbage
collector is free to have it's way with it.
Thanks.

Hi,

You can call Dispose if it implement it, and you can set it to null.
this will free the memory IF (and that's a capital if) it's not
referenced somewhere else,like for example in a DataSet
Then you can call

System.GC.Collect(); to force garbage collection.
Jun 27 '08 #3
On May 29, 3:08*pm, Marc S <msci...@osmose.comwrote:
On May 29, 12:03*pm, "Ignacio Machin ( .NET/ C# MVP )"

<ignacio.mac...@gmail.comwrote:
On May 29, 11:38*am, "Jordan S." <A...@B.comwrote:
How can get rid of a DataTable instance?
Set it to null + call Dispose on it? *Anything else? Is Dispose really
necessary given that the DataTable doesn't hold any resources (AFAIKT)?
Yes, I know there is no deterministic finalization - but I want to do my
best to tell the system that I'm done with the DataTable ... and the garbage
collector is free to have it's way with it.
Thanks.
Hi,
You can call Dispose if it implement it, and you can set it to null.
this will free the memory IF (and that's a capital if) it's not
referenced somewhere else,like for example in a DataSet

Then you can call

System.GC.Collect(); *to force garbage collection.- Hide quoted text -

- Show quoted text -
Unless you have a REAL justification I would leave the GC work his
magic alone
Jun 27 '08 #4
Jordan S. wrote:
How can get rid of a DataTable instance?

Set it to null + call Dispose on it? Anything else? Is Dispose really
necessary given that the DataTable doesn't hold any resources (AFAIKT)?

Yes, I know there is no deterministic finalization - but I want to do my
best to tell the system that I'm done with the DataTable ... and the garbage
collector is free to have it's way with it.

Thanks.
General rule is to always call Dispose on objects that implement the
IDisposable pattern, when you're done with the object.

DataTable implements IDisposable since it inherits from
MarshalByRefComponent, and doesn't even override Dispose, so basically
the only code involved in IDisposable for a DataTable is what's in
MarshalByRefComponent.

Unless you have specific reasons for *not* calling Dispose, don't
second-guess what the code does and just call it.

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3
Jun 27 '08 #5
On May 29, 5:15*pm, "Ignacio Machin ( .NET/ C# MVP )"
<ignacio.mac...@gmail.comwrote:
On May 29, 3:08*pm, Marc S <msci...@osmose.comwrote:


On May 29, 12:03*pm, "Ignacio Machin ( .NET/ C# MVP )"
<ignacio.mac...@gmail.comwrote:
On May 29, 11:38*am, "Jordan S." <A...@B.comwrote:
How can get rid of a DataTable instance?
Set it to null + call Dispose on it? *Anything else? Is Dispose really
necessary given that the DataTable doesn't hold any resources (AFAIKT)?
Yes, I know there is no deterministic finalization - but I want to do my
best to tell the system that I'm done with the DataTable ... and thegarbage
collector is free to have it's way with it.
Thanks.
Hi,
You can call Dispose if it implement it, and you can set it to null.
this will free the memory IF (and that's a capital if) it's not
referenced somewhere else,like for example in a DataSet
Then you can call
System.GC.Collect(); *to force garbage collection.- Hide quoted text -
- Show quoted text -

Unless you have a REAL justification I would leave the GC work his
magic alone- Hide quoted text -

- Show quoted text -
I would say that is correct. Unless you have a cheapie company that
has low end machines and your data tables are large wait for the
garbage collector to do its thing automatically. If you jsut really
want to for=ce everything to be scrubbed the option is there. I would
think by .NET 3.5 they would have all of the kinks worked out of
manual garbage collection but I haven't had to use it in a long time
since we have decent machines here and I have learned to slim down my
footprint.
Jun 27 '08 #6
Marc S wrote:
On May 29, 5:15 pm, "Ignacio Machin ( .NET/ C# MVP )"
<ignacio.mac...@gmail.comwrote:
>On May 29, 3:08 pm, Marc S <msci...@osmose.comwrote:


>>On May 29, 12:03 pm, "Ignacio Machin ( .NET/ C# MVP )"
<ignacio.mac...@gmail.comwrote:
On May 29, 11:38 am, "Jordan S." <A...@B.comwrote:
How can get rid of a DataTable instance?
Set it to null + call Dispose on it? Anything else? Is Dispose really
necessary given that the DataTable doesn't hold any resources (AFAIKT)?
Yes, I know there is no deterministic finalization - but I want to do my
best to tell the system that I'm done with the DataTable ... and the garbage
collector is free to have it's way with it.
Thanks.
Hi,
You can call Dispose if it implement it, and you can set it to null.
this will free the memory IF (and that's a capital if) it's not
referenced somewhere else,like for example in a DataSet
Then you can call
System.GC.Collect(); to force garbage collection.- Hide quoted text -
- Show quoted text -
Unless you have a REAL justification I would leave the GC work his
magic alone- Hide quoted text -

- Show quoted text -

I would say that is correct. Unless you have a cheapie company that
has low end machines and your data tables are large wait for the
I don't think you should need to manually call the garbage collector on
any machine at all.

The garbage collector registers with Windows for low-memory conditions,
and will, when needed, start to run more often if some other application
needs the memory. In other words, GC will run as often as required.
garbage collector to do its thing automatically. If you jsut really
want to for=ce everything to be scrubbed the option is there. I would
think by .NET 3.5 they would have all of the kinks worked out of
manual garbage collection but I haven't had to use it in a long time
since we have decent machines here and I have learned to slim down my
footprint.

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3
Jun 27 '08 #7
On May 30, 8:09*am, Lasse Vågsæther Karlsen <la...@vkarlsen.nowrote:
Marc S wrote:
On May 29, 5:15 pm, "Ignacio Machin ( .NET/ C# MVP )"
<ignacio.mac...@gmail.comwrote:
On May 29, 3:08 pm, Marc S <msci...@osmose.comwrote:
>On May 29, 12:03 pm, "Ignacio Machin ( .NET/ C# MVP )"
<ignacio.mac...@gmail.comwrote:
On May 29, 11:38 am, "Jordan S." <A...@B.comwrote:
How can get rid of a DataTable instance?
Set it to null + call Dispose on it? *Anything else? Is Dispose really
necessary given that the DataTable doesn't hold any resources (AFAIKT)?
Yes, I know there is no deterministic finalization - but I want to do my
best to tell the system that I'm done with the DataTable ... and thegarbage
collector is free to have it's way with it.
Thanks.
Hi,
You can call Dispose if it implement it, and you can set it to null.
this will free the memory IF (and that's a capital if) it's not
referenced somewhere else,like for example in a DataSet
Then you can call
System.GC.Collect(); *to force garbage collection.- Hide quoted text-
- Show quoted text -
Unless you have a REAL justification I would leave the GC work his
magic alone- Hide quoted text -
- Show quoted text -
I would say that is correct. Unless you have a cheapie company that
has low end machines and your data tables are large wait for the

I don't think you should need to manually call the garbage collector on
any machine at all.

The garbage collector registers with Windows for low-memory conditions,
and will, when needed, start to run more often if some other application
needs the memory. In other words, GC will run as often as required.
garbage collector to do its thing automatically. *If you jsut really
want to for=ce everything to be scrubbed the option is there. *I would
think by .NET 3.5 they would have all of the kinks worked out of
manual garbage collection but I haven't had to use it in a long time
since we have decent machines here and I have learned to slim down my
footprint.

--
Lasse Vågsæther Karlsen
mailto:la...@vkarlsen.nohttp://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3- Hide quoted text -

- Show quoted text -
See, when I was working in 1.1 that wasn't always true. The system did
a lot of swapping when it had dead objects it could clean up which is
why I did it back then. I would hope things are different now but I
haven't been forced to use it. I guess my thoughts are based on old
technology at this point.
Jun 27 '08 #8

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

Similar topics

5
2231
by: randy | last post by:
Hello all, I have a DataTable which I am building column by column and adding rows after each new column. The DataTable columns match the columns in my database table. I'm building the DataTable first and I then want to roll through the DataTable while in memory checking for errors and then commit the rows to my database table (btw this...
5
10012
by: Stefan Turalski \(stic\) | last post by:
Hi, I'm wondering if there is a way to send a method parametrs by ref when DataTabel is a type of this value ? I done some sort of select over DataTable columns, just by removing them froma table is each of them isn't on a stirng, but right no I have to do it in a wat of: 1. passing DataTable to method (lets call it SelectOverDataTabel)...
1
5851
by: TaeHo Yoo | last post by:
Hi all, After sorting and grouping data using a dataview, then how to transfer the changed datatable in the dataview to a datatable in C#? Cheers
0
3129
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these datacolumns do not trigger their expression when other columns from which the expressions are derived are updated. Below is a basic example of what...
7
1647
by: Raymond Lewallen | last post by:
Which would be the proper way or the reason for using any of the following or combinations of the following? These are the 3 ways I've figured I can do what I want to do, I just don't know which would be best: #1 ' Everything is create upon instantiation. Once completed, datatable can be obtained from the property. Public Class A ...
3
4203
by: Gene Hubert | last post by:
I'm using DataTable.ImportRow to move data from one datatable to another... Dim dt, dtTarget As DataTable Dim dr As DataRow dt = DirectCast(Me.DataSource, DataTable) dtTarget = dt.Clone 'copy the data structure dtTarget.DefaultView.Sort = String.Empty 'remove the sort
3
3177
by: Jon | last post by:
I'm learning about datatables. When using the example provided by MS in the ..NET Framework Class Library for DATATABLE (see below) I get an error on line 3 that says "Type expected". Is something missing from the code? Thanks - Jon Private Sub MakeParentTable() ' Create a new DataTable. Dim myDataTable As Datatable = New...
6
28293
by: Pete Wittig | last post by:
Hi, I have a DataTable and I want to get a subset of the rows within it. I use the Select method to get my subset and the results are in a DataRow. I want to put those Rows back into a DataTable. I've tried a few variations of the following but no rows are every imported into the datatable: DataRow datrow = ds.Tables.Select("PersonID =...
0
1762
by: Maart_newbie | last post by:
Hi all, I've got a question about returning the value of a pk-column to a DataTable after inserting a row (via a data-adapter) using MySql5. Here is the SQL and code concerned: //=================================================================== // The table
5
8615
by: Frank Hauptlorenz | last post by:
Hello, I recognized some days ago, that returning a DataTable blocks my WCF-Service. Is this a known bug? If I add this table to a new DataSet() and return this, it works. Thank you, Frank
0
7270
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7178
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7397
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7128
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5704
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5103
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4759
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3255
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.