Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Use of Dispose on Diagram and DiagramView (Read 492 times)
David Long
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 94
Location: England
Joined: Oct 23rd, 2006
Use of Dispose on Diagram and DiagramView
Dec 4th, 2019 at 1:10pm
Print Post  
When closing a Windows Form is there a best practice for disposing of the Diagram and DiagramView instances?  Do I have to explicitly do this?  When opening and closing a large number of files and creating these objects I start to get low on memory, so it seems I'm not disposing of something correctly!

Any help gratefully received.

David
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 2164
Joined: Oct 19th, 2005
Re: Use of Dispose on Diagram and DiagramView
Reply #1 - Dec 5th, 2019 at 6:48am
Print Post  
Hi,

Check if there aren't some variables left in the application pointing to DiagramView, Diagram or any nodes/links. You should be able to find what prevents GC from disposing of objects using VS Diagnostic Tools -> Memory Usage -> Take Snapshot. Call that after closing your form, click View Heap and find if there's any DiagramView instance left. Select it and check the 'Paths to Root' pane - items showing [Cycle Detected] are safe, while ones leading to variables in parent form or some static references need to be cleared.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
David Long
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 94
Location: England
Joined: Oct 23rd, 2006
Re: Use of Dispose on Diagram and DiagramView
Reply #2 - Dec 5th, 2019 at 4:09pm
Print Post  
Thanks for your help. It seems that I am hanging on to a reference to the whole Form that contains the DiagramView. The 'Paths to root' pane does not seem too helpful, so I might try a different memory diagnostic tool or revisit the problem another day!

Thanks again
David

Edit: 'Paths to root' was actually useful, I just didn't know what I was looking at! The problem is the many event handlers that have a reference to the form - apparently a know problem.  Sad
« Last Edit: Dec 5th, 2019 at 8:43pm by David Long »  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint