I\'ve encountered somewhat of a problem in MEF\'s part lifetime which causes memory leaks in my Prism application.
My application exports views and viewmodels with t
Unless Prism supports some kind of lifetime for view objects, there is no solution here except to remove IDisposable from the list of interfaces exposed by the view.
There are three MEF approaches to handling this problem, all mentioned by other responders:
ExportFactoryReleaseExport()All of them require some work on the part of the code that requests the original export - in this case code within Prism. This makes some sense, as it is undesirable for code consuming an object to have to be aware of how and when it was created.
There is no ReleaseExportedObject() in MEF because multiple (e.g. property) exports can return the same value; it may be logically possible to provide but the added complexity makes it unlikely to be addressed by MEF in the foreseeable future.
Hope this helps; I've retagged this question 'prism' as I'm sure others in the Prism community will have encountered this and be able to offer advice.