dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Pnet-developers] [bug #16089] Garbage Collector does not call Final


From: Christopher Sawyer
Subject: Re: [Pnet-developers] [bug #16089] Garbage Collector does not call Finalizers if using Forms
Date: Wed, 15 Mar 2006 00:18:56 -0500
User-agent: KMail/1.7.2

He used the "new" keyword, which means this instance is not static, it's an 
instance.

You could have some child control on Form2 that's holding the GC back from 
garbage collecting entire Form.  The easiest way to find out is to implement 
IDisposable (which forms already do, look for your Dispose() method) and log 
what's in your Controls collection out to a file.

Then, implement a destructor on Form2 and log that event as well to make sure 
that this stuff is indeed not freeing up (i.e. never getting called or hangs 
when it runs).

Sample code to add to Form2:

public void Dispose()
{
  System.Console.WriteLine("Form2 is being disposed of.");
 foreach(object o in Controls)
 {
  System.Console.WriteLine("Control found ->" + o.GetType().ToString());
 }
}

~Form2()
{
    /* code that logs something somewhere (maybe a file?) */
}

On Tuesday 14 March 2006 08:58 am, Marc Haisenko wrote:
> On Tuesday 14 March 2006 14:48, address@hidden wrote:
> > Look at my small sample.
> >
> > Just do:
> >
> > new Form2().Show();
> >
> > So the Form2 is shown, and never had a reference on it.
> > When Closing the Form gc.should collect.
>
> Ahh, now I understand... after reading through the source I thought "no
> wonder nothing gets collected, there's a static reference to a Form1
> instance that never gets set to null"
>
> And on Windows Form2 gets collected ?
>
> > Problem must be in Xsharp/Widget.cs or?!??
>
> Do you already have a clue or something ?
>
> C'ya,
>  Marc


reply via email to

[Prev in Thread] Current Thread [Next in Thread]