سؤال

When a user clicks on a WinForms menu item, this code gets executed:

 // this is an Infragistics XamRibbonWindow
var someWpfInfragisticsWindow = new SomeWpfInfragisticsWindow();
ElementHost.EnableModelessKeyboardInterop(someWpfInfragisticsWindow);
someWpfInfragisticsWindow.Show();

The window that is shown is an Infragistics XamRibbonWindow. It also contains an Infragistics XamDataGrid whose DataSource is bound to an IEnumerable property on the view model.

The window also contains a 'Search' button that will retrieve a new collection of items from a database, and set the previously mentioned view model property. This causes the grid to display the new collection.

Later on, the user may close the window. No code was written to handle the close.

My questions are:

  1. Does closing the window dispose of the window, its controls and make the collection bound to it GC-able (assuming no other references to the collection exist)?
  2. Does anyone see any potential memory issues with what I've described? Perhaps with the way the items displayed by the grid is updated (or anything else)?
هل كانت مفيدة؟

المحلول

When the Window is closed if you haven't held a reference to it it should be available for garbage collection. I don't see any memory issues with this approach from the details provided.

Note that Infragistics does have some static classes that will remain after you close the window.

If you do have memory leak issues using the Infragistics controls and believe that the controls may be the cause you should reach out to Infragistics for assistance determining the cause of the leak. There are links to post on the forums or submit a support case from the get help page.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top