M
MuZZy
Hi All,
I got a issue here and hope someone can help me:
Let's consider this code:
// =================== CODE START =================================
using System;
using System.Data;
namespace TestNamespace
{
public class Test
ataSet
{
public static int i = 0;
public Test():base(){i++;}
~Test(){i--;}
}
public class MainClass
{
[STAThread]
public static void Main(string[] args)
{
Console.WriteLine("Generating Garbage:");
for (int i = 0 ; i < 10 ; i ++) {
Test t = new Test();
}
Console.WriteLine("Collecting Garbage: " + Test.i.ToString());
GC.Collect();
GC.WaitForPendingFinalizers();
Console.WriteLine("Objects not finalized: "+ Test.i.ToString());
}
}
}
// =================== CODE END ===================================
This will compile into a console app - you can just copy and paste in a cs file.
So, if you run this, you will see that Test objects are created but never finalized.
Now, if you comment out "
ataSet" (to NOT inherit from DataSet),
all created Test objects are finalized fine.
I guess my mistake is in the way i inherit from DataSet, but can't figure out what exactly..
Any ideas would be appreciated!!!
Thank you,
Andrey
I got a issue here and hope someone can help me:
Let's consider this code:
// =================== CODE START =================================
using System;
using System.Data;
namespace TestNamespace
{
public class Test

{
public static int i = 0;
public Test():base(){i++;}
~Test(){i--;}
}
public class MainClass
{
[STAThread]
public static void Main(string[] args)
{
Console.WriteLine("Generating Garbage:");
for (int i = 0 ; i < 10 ; i ++) {
Test t = new Test();
}
Console.WriteLine("Collecting Garbage: " + Test.i.ToString());
GC.Collect();
GC.WaitForPendingFinalizers();
Console.WriteLine("Objects not finalized: "+ Test.i.ToString());
}
}
}
// =================== CODE END ===================================
This will compile into a console app - you can just copy and paste in a cs file.
So, if you run this, you will see that Test objects are created but never finalized.
Now, if you comment out "

all created Test objects are finalized fine.
I guess my mistake is in the way i inherit from DataSet, but can't figure out what exactly..
Any ideas would be appreciated!!!
Thank you,
Andrey