Posted 19 years ago by kh - United Kingdom
Avatar
Hi. I read another post on this group but the proposed solution does not work. The child of my window needs to be disposed and dereferenced, so I have trapped the DWManager window closing/closed events as described. Memory profiling shows that my control is still in memory. It is referenced from:
  
ActiproSoftware.TabStripPanel.TabStripPanelItem
System.Windows.Forms.Control+ControlNativeWindow
I have tried to fix this using the following (where manager is my DWManager object)

private void manager_DocumentWindowClosing(object sender, DWDocumentWindowEventArgs e)
{
    KillDocumentWindow( e.DocumentWindow );
}
private void manager_DocumentWindowClosed(object sender, DWDocumentWindowEventArgs e)
{
    KillDocumentWindow( e.DocumentWindow );
}
private void KillDocumentWindow( DWDocumentWindow win )
{
    Control child = win.Child;
    if( child != null )
    {
        if( child.Parent != null )
            child.Parent.Controls.Remove( child );
        child.Dispose();
    }
}
Can you please suggest how I can fix this. I am using v2.00.0207

kh

Comments (9)

Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
We remove the child reference right after DocumentWindowClosed is raised. So if you disposed it in DocumentWindowClosed, after the final line of our code executes there should no longer be a reference to it.

So essentially, if you are checking in DocumentWindowClosed, there will still be a reference. If you check after, there should no longer be one.


Actipro Software Support

Posted 19 years ago by kh - United Kingdom
Avatar
Quote:
<font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Actipro Software Support:
We remove the child reference right after DocumentWindowClosed is raised. So if you disposed it in DocumentWindowClosed, after the final line of our code executes there should no longer be a reference to it.

So essentially, if you are checking in DocumentWindowClosed, there will still be a reference. If you check after, there should no longer be one.
<HR>


Thanks for your reply.

Yes, I am checking AFTER DocumentWindowClosed has been called. I am using ANTS Profiler. I run my application, create a new document window, close it, then take a snapshot using ANTS. It shows that my control is still in memory because a reference to it is held by an instance of ActiproSoftware.TabStripPanel.TabStripPanelItem

According to ANTS, the TabStripPanelItem was created according to the following call stack (I have used [] to denote obfuscated method names):

DWManager.CreateDocumentWindow( string, string, int, Control )
DWDocumentWindowCollection.[]( DWDocumentWindow )
DWDocumentWindowCollection.[]( int, DWDocumentWindow )
DWManager.[]( DWWindowBase, bool )
DWWindowBaseCollection.[]( DWWindowBase, bool )
DWWindowBaseCollection.[]( int, DWWindowBase, bool )

I have even tried calling GC.Collect() after I have closed the window. Because your code is obfuscated I cannot trace the error, so I can only post my observations. How else might I be able to trace what is causing this?

kh
Posted 19 years ago by kh - United Kingdom
Avatar
By the way, I have changed my code so that I only dispose the child in the DocumentWindowClosed event. During this event the childControl.Parent property is ALWAYS null. This seems to conflict with the sample code you gave in response to a similar question to this channel. Could this indicate a problem elsewhere in my code?

Here is the sample code you gave:
 
Control childControl = dw.Child;
childControl.Parent.Controls.Remove(childControl);
childControl.Dispose();
Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I've got the memory profiler going now and I see what you mean. I'll track it down and post back soon.


Actipro Software Support

Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Ok, I think I found where the problem is and removed the TabStripPanelItem reference to the child control. This fix will be in the next maintenance release.


Actipro Software Support

Posted 19 years ago by kh - United Kingdom
Avatar
Thanks for your efforts. Any idea when this will be available?

For the time being I have cleaned up as much as possible so that the "phantom" control hogs as little memory as possible.

kh

[ 03-15-2005: Message edited by: kh ]

[ 03-15-2005: Message edited by: kh ]
Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
There should be a maintenance release for DockableWindow very soon.

However note that now that UIStudio has been released, it will take the place of DockableWindow going forward. I'd highly recommend that you check it out and consider moving to that product. Upgrade pricing is available to all DockableWindow customers.


Actipro Software Support

The latest build of this product (v2.0.0208) was released 19 years ago, which was before the next post in this thread.
Posted 18 years ago by Mark - Greenville, SC
Avatar
Was this ever 'fixed', or is the answer to 'upgrade'?
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The last build we have here has the fix listed in the readme's Release History. That build was 2.0.0208.


Actipro Software Support