none
Why the Non Shared object in CatalogExportProvider is not released for garbage collection? RRS feed

  • Question

  • What is the lifetime of a composed NonShared object?


    For example: if we created a View Model object using an ExportFactory<object, Metadata> (the Metadata being used to resolve what kind of VM needs to be created) and the only reference to the ViewModel is the DataContext of the View. What should happen to the ViewModel when the View is destroyed? 

    In our case the ViewModel stays in memory even after calling GC explicitly and it remains in memory until the application is terminated. 

    From the profiling tool we can see that the ViewModel is held in a Hashset<IDisposables> by the CatalogExportProvider             

    Please see the attached snapshot.

    Saturday, April 12, 2014 9:09 AM

Answers

All replies

  • Hi Zeeshan,

    See a similar discussion about object destruction problem with MEF. http://stackoverflow.com/questions/4368217/object-destruction-problem-with-mef. Hope helpful.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 14, 2014 5:33 AM
    Moderator
  • Hi Zeeshan,

    See a similar discussion about object destruction problem with MEF. http://stackoverflow.com/questions/4368217/object-destruction-problem-with-mef. Hope helpful.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Hi Herro, 

    Thank you for your help. This discussion is the exact match for my problem, but it suggests the use of ExprotFactory, which unfortunately is not available in .Net Framework 4.0. Can you suggest any workaround for this?

    Regards,
    Wednesday, April 16, 2014 1:24 AM
  • Hi Herro,

    Thanks again. The second option mentioned in the discussion by using "ReleaseExport" method can release the instance and disposes it.

    Regards,

    Wednesday, April 16, 2014 2:15 AM