Your last statement about DataTable refs and DataSet refs is very
interesting.
Could you give me a bit more explanation on what you mean?
Do you mean that if i don't clear DataSetExtended->Tables->Clear() it
won't be GC'd?
Even if i do DataSetExtended = null; ?
Why? The obect is dereferenced, Tables are contained in it, reference is
internal...
AM I MISSING SOMETHING??? I know i am

Pls HELP!!!
I'm going nuts with app, frankly
I guess, I can better illustrate this by means of a sample.
Compile following code, and run it from the console, start perfmon and watch
the GC counters (CLR memory object).
You will see that as long as the DataSet contains tables, it won't get
collected. Don't forget that the actual size of a DataSet is the size of
it's contained table(s) data.
// Begin
using System;
using System.Data;
class Tester
{
static void Main()
{
using(DataSet custDS = new DataSet("Test"))
{
Console.WriteLine("Start perfmon, select counters and press <Enter> when
done");
Console.ReadLine(); // this gives you the opportunity to start permon
and select the GC counters.
DataTable dt = Build(custDS);
// Check - does the table belongs to a dataset?
if (dt.DataSet != null) // NOTE this property is read-only and holds a
reference to the containing DataSet!!!!
{
Console.WriteLine("Detach all tables");
// Remove tables from the collection,
// comment following statement and watch the perf counters...
dt.DataSet.Tables.Clear();
// or remove a single table from the collection
// dt.DataSet.Tables.Remove (dt);
// Check again...
if (dt.DataSet == null)
Console.WriteLine("DS reference cleared, press <Enter> to force GC");
}
Console.ReadLine();
// Force a collection (only for demo purpose)
GC.Collect();
}
Console.ReadLine();
}
// Fill a table with data and add it to the DataSet
private static DataTable Build(DataSet ds){
DataTable dt = ds.Tables.Add("MyTable");
DataColumn dcol;
DataRow drow;
dcol = new DataColumn();
dcol.DataType = System.Type.GetType("System.Int32");
dcol.ColumnName = "id";
dt.Columns.Add(dcol);
dcol = new DataColumn();
dcol.DataType = Type.GetType("System.String");
dcol.ColumnName = "item";
dt.Columns.Add(dcol);
// Add some data
for(int i = 0; i < 50000; i++){
drow = dt.NewRow();
drow["id"] = i;
drow["item"] = "item " + i;
dt.Rows.Add(drow);
}
return dt;
}
}
// End code
Willy.