S
Steve Drake
All,
I am playing with WinDBG and SOS.
If I run !FinalizeQueue
I get
SyncBlock to be cleaned up: 0
----------------------------------
generation 0 has 6 finalizable objects (0x0015a370->0x0015a388)
generation 1 has 0 finalizable objects (0x0015a370->0x0015a370)
generation 2 has 0 finalizable objects (0x0015a370->0x0015a370)
Ready for finalization 0 objects (0x0015a388->0x0015a388)
All Finalizable Objects Statistics:
MT Count TotalSize Class Name
0x00935120 3 36 ConsoleApplication12.GoodClass
0x79bd9a14 3 156 System.IO.StreamWriter
why do i see GoodClass? i have called dispose on this, see my code at the
end.
I am trying to workout if my very large app is disposing objects correctly,
using winDBG sugested that it wasent, but i was sure that it was, so i wrote
this test project and it also does not seam to dispose objects.
Here is the code :
using System;
using System.Threading;
namespace ConsoleApplication12
{
class BadClass
{
public BadClass()
{
System.Console.WriteLine("Hello");
}
~BadClass()
{
System.Console.WriteLine("Sleep");
Thread.Sleep(Timeout.Infinite);
}
}
class GoodClass : IDisposable
{
public GoodClass()
{
System.Console.WriteLine("Hello");
}
~GoodClass()
{
System.Console.WriteLine("Sleep");
Thread.Sleep(Timeout.Infinite);
}
#region IDisposable Members
public void Dispose()
{
// TODO: Add GoodClass.Dispose implementation
System.Console.WriteLine("Bye ");
GC.SuppressFinalize(this);
}
#endregion
}
class EntryPoint
{
static void Main(string[] args)
{
/* BadClass b1 = new BadClass();
BadClass b2 = new BadClass();
BadClass b3 = new BadClass();
*/
GoodClass g1 = new GoodClass();
GoodClass g2 = new GoodClass();
GoodClass g3 = new GoodClass();
g1.Dispose();
g2.Dispose();
g3.Dispose();
/*
System.GC.Collect();
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
*/
Console.WriteLine("Done");
Console.ReadLine();
}
}
}
I am playing with WinDBG and SOS.
If I run !FinalizeQueue
I get
SyncBlock to be cleaned up: 0
----------------------------------
generation 0 has 6 finalizable objects (0x0015a370->0x0015a388)
generation 1 has 0 finalizable objects (0x0015a370->0x0015a370)
generation 2 has 0 finalizable objects (0x0015a370->0x0015a370)
Ready for finalization 0 objects (0x0015a388->0x0015a388)
All Finalizable Objects Statistics:
MT Count TotalSize Class Name
0x00935120 3 36 ConsoleApplication12.GoodClass
0x79bd9a14 3 156 System.IO.StreamWriter
why do i see GoodClass? i have called dispose on this, see my code at the
end.
I am trying to workout if my very large app is disposing objects correctly,
using winDBG sugested that it wasent, but i was sure that it was, so i wrote
this test project and it also does not seam to dispose objects.
Here is the code :
using System;
using System.Threading;
namespace ConsoleApplication12
{
class BadClass
{
public BadClass()
{
System.Console.WriteLine("Hello");
}
~BadClass()
{
System.Console.WriteLine("Sleep");
Thread.Sleep(Timeout.Infinite);
}
}
class GoodClass : IDisposable
{
public GoodClass()
{
System.Console.WriteLine("Hello");
}
~GoodClass()
{
System.Console.WriteLine("Sleep");
Thread.Sleep(Timeout.Infinite);
}
#region IDisposable Members
public void Dispose()
{
// TODO: Add GoodClass.Dispose implementation
System.Console.WriteLine("Bye ");
GC.SuppressFinalize(this);
}
#endregion
}
class EntryPoint
{
static void Main(string[] args)
{
/* BadClass b1 = new BadClass();
BadClass b2 = new BadClass();
BadClass b3 = new BadClass();
*/
GoodClass g1 = new GoodClass();
GoodClass g2 = new GoodClass();
GoodClass g3 = new GoodClass();
g1.Dispose();
g2.Dispose();
g3.Dispose();
/*
System.GC.Collect();
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
*/
Console.WriteLine("Done");
Console.ReadLine();
}
}
}