- Welcome, Guest. Please Login or Register
MindFusion  
  We have released initial version of MindFusion.JavaScript pack. It includes chart, diagram, calendar, map, virtual keyboard, gauge and UI components. Here are more details and live demo for anyone interested.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
Use of Dispose on Diagram and DiagramView
Read 96 times

David Long   Offline
Junior Member
**
Posts: 87
Gender: male
England
I love YaBB 1G - SP1!


   
     
 
Use of Dispose on Diagram and DiagramView
Dec 4th, 2019 at 1:10pm
 
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
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1912
Gender: male
tech.support


   
     
 
Re: Use of Dispose on Diagram and DiagramView
Reply #1 - Dec 5th, 2019 at 6:48am
 
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
 
 
 
IP Logged    
 
     

David Long   Offline
Junior Member
**
Posts: 87
Gender: male
England
I love YaBB 1G - SP1!


   
     
 
Re: Use of Dispose on Diagram and DiagramView
Reply #2 - Dec 5th, 2019 at 4:09pm
 
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 »
 
IP Logged    
 
     
Page Index Toggle Pages: 1 Send Topic Print