Red Gate forums :: View topic - empty form not disposing?
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
ANTS Memory Profiler Previous Versions
ANTS Memory Profiler Previous Versions forum

empty form not disposing?

Search in ANTS Memory Profiler Previous Versions forum
Post new topic   Reply to topic
Jump to:  
Author Message
bobenjamins



Joined: 05 Aug 2009
Posts: 2

PostPosted: Wed Aug 05, 2009 4:58 pm    Post subject: empty form not disposing? Reply with quote

Hi,

I've tried the memory profiler and am having trouble understand the output completely.

To make it easier for me i created a fresh .net app with a mdi form opening a basic blank form.

when i ran the profiler i found un-disposed instances of the blank form still in memory (from just opening the form from a menu and closing).

i did this by taking a snapshot while the mdi was running, then again after i had opened and closed the form.

the code on the mdi menu is:

Dim frm As New Baby
frm.MdiParent = Me
frm.Show()

Could it be that the frm would be disposed of eventually? Currently it seems that it stays in memory forever. within the redgate memory profiler when i choose the tickbox to display those diposed objects which are still in memory - it still displays the instance of the Baby form.

how is this possible?

the baby form contains nothing:

Public Class Baby
inherits form
End Class
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6589

PostPosted: Thu Aug 06, 2009 5:22 pm    Post subject: Reply with quote

Hi,

I couldn't say why there is still a reference to the form -- it must be held from the parent form. Unfortunately I've never written any MDI forms.

You can use the Object Retention Graph for the form object to work out where the reference is being held. First, highlight the class, then click "Instance List" and then on the object retention graph symbol. The graph will point out the reference chain for that object.
Back to top
View user's profile Send private message
bobenjamins



Joined: 05 Aug 2009
Posts: 2

PostPosted: Fri Aug 07, 2009 9:51 am    Post subject: Reply with quote

Hi,

Yes I used the graphs but stripped everything down to a basic mdi example to highlight that it indicated that memory was still not released.

The only way i am able to get the mdi to release the references once the child form is closed is to set the frm.MdiParent = nothing.

which effectively stops the child from being held within the mdi.

Your product is excellent and I would like to use it within our real app, but hesitate given that i can't seem to get results during this basic mdi app.
Basic in that all i've done is created a new mdi form and added a menu item with the call to open a blank child form.

I'm not sure if this is a problem with red gate (probably not) or if windows mdi forms just don't release references.
Back to top
View user's profile Send private message
Chris.Allen



Joined: 12 Mar 2009
Posts: 547

PostPosted: Thu Aug 13, 2009 11:56 am    Post subject: Reply with quote

Could you please send an exported object retention graph (as pdf) to support@red-gate.com. This will help me analyse what is going on (pictures saves a thousand words**, and all that Smile. Thank you.

Chris.

* but take 10,000 times the memory!
Back to top
View user's profile Send private message
Kearney



Joined: 25 Aug 2009
Posts: 2
Location: Scotland

PostPosted: Tue Aug 25, 2009 9:31 pm    Post subject: Reply with quote

Hi bobenjamins,

Did you manage to get a solution to this MDI problem. I'd be very interested to know your solution.

Can you reply either way, so I know i can eliminate this topic for a potnetial solution.

Thanks in advance,
Stuart
Back to top
View user's profile Send private message Send e-mail
David.Narraway



Joined: 23 Oct 2009
Posts: 14
Location: Oulu, Finland

PostPosted: Wed Nov 18, 2009 9:08 am    Post subject: Reply with quote

I've seen something like this problem as well, though it is with a C# forms application. The OP initially refers to "un-disposed instances", but subsequently indicates that the instance has been disposed but is still in memory.

Well reassuringly it seems there is a bug in the .NET framework. It is described in this article (http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=428857) without a suggested work around. Fortunately a more complete article with a workaround can be found at http://www.scitech.se/blog/index.php/2008/03/20/minor-memory-leak-introduced-in-net-framework-20-sp1.

I have implemented the workaround described and can confirm that it solves the problem. You should note though that the reference will change anyway if/when another MDI child becomes the last active one. At that time the earlier one will be collected. So in a live system this probably isn't a big deal, but when using a memory profiler it does mis-lead.

I've seen a similar problem with a DevExpress tree component, but I have yet to find / come up with a workaround. I guess a simple example sent to DevExpress is the way forward.

Regards,
David.
Back to top
View user's profile Send private message
Kearney



Joined: 25 Aug 2009
Posts: 2
Location: Scotland

PostPosted: Wed Nov 18, 2009 1:39 pm    Post subject: Reply with quote

Thanks for Sharing David
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group