Help with a form not released

Questions about YourKit .NET Profiler
Post Reply
ajh
Posts: 1
Joined: Tue May 27, 2008 11:18 pm

Help with a form not released

Post by ajh »

I am pulling my hair out trying to figure out why a closed form is still appearing in the memory list.

When I select it, under the 'Merged paths to objects...', the item in the tree says "Objects are roots themselves"

When I select the form and choose "Paths from GC Roots...", I see in the tree :

- NAME OF FORM [Stack Local]
control of System.Windows.Forms.Control/ControlNativeWindow {GC Handle]

Can you help me out with this?

Thanks!
Vladimir Kondratyev
Posts: 1624
Joined: Tue Aug 10, 2004 7:52 pm

Re: Help with a form not released

Post by Vladimir Kondratyev »

It seems that reference to form object is stored in some local variable of method which never finishes.
Tobbe
Posts: 72
Joined: Thu Feb 21, 2008 11:08 am

Re: Help with a form not released

Post by Tobbe »

ajh wrote:
When I select the form and choose "Paths from GC Roots...", I see in the tree :

- NAME OF FORM [Stack Local]
control of System.Windows.Forms.Control/ControlNativeWindow {GC Handle]

Can you help me out with this?

Thanks!
We had a simalar problem, cant remember exact what it was, think its a static event that is holding the reference. Or you have implemented a static field of some sort in the form as Vladimir says, Use...

Code: Select all

using(MyForm form = new MyForm()) 
{
...
...
}
...to ensure correct dispose.

Funny thing, is that we had to use another profiler (demo version) to detect the details what event it was...
Post Reply