tag:blogger.com,1999:blog-393540894130950585.post7080763217976109607..comments2024-03-22T00:23:29.865-07:00Comments on Never In Doubt: Event Aggregator in Prism ExplorerWard Bellhttp://www.blogger.com/profile/10977457957771020146noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-393540894130950585.post-41153335099405391662009-06-15T19:51:23.331-07:002009-06-15T19:51:23.331-07:00You’ve got a very interesting case.
I don’t know ...You’ve got a very interesting case.<br /><br />I don’t know if you’ve passed it along to the SL team. I have an idea why this might be happening … and it would be so fundamental to WPF / SL that you’d think there would be literature on it.<br /><br />My speculation (it is only that) is that because DataContext is a DependencyProperty, unlike Tag, there is some other class somewhere … not the View Class … that is holding the ViewModel … and doing so on the behalf of the View. The View doesn’t actually have a reference to the VM; that “other” class has the reference; as with all DPs, that other class is (under the covers) maintaining an association between your view class and the VM. Now, according to this theory, that class should also prevent your View from being GC’d. But maybe it holds a weak reference to your view.<br /><br />Again … I’m just guessing. This is definitely a good question for the SL and WPF boards.<br /><br />Please let me know if you get anywhere with this.Ward Bellhttps://www.blogger.com/profile/10977457957771020146noreply@blogger.comtag:blogger.com,1999:blog-393540894130950585.post-74035729035526921632009-06-14T05:51:12.560-07:002009-06-14T05:51:12.560-07:00Hi Ward,
We are building a Silverlight LOB appli...Hi Ward,<br /> <br />We are building a Silverlight LOB application using prism and plan on using your devforce product (which we are really excited about). Your prism explorer application is proving particularly useful in understanding both prism and the MVVM architecture so thanks. In terms of implementing MVVM, and considering this post, I was wondering if you are aware of the memory leak in Prism Explorer, which is associated with the FormView and FormViewModel. Basically, neither the FormView nor FormViewModel is GC'd when the view is closed. <br />I also wonder if I’m completely missing something as we have encountered a number of similar memory leaks in our application. Basically, we are using something similar to your coordinator to load a view into a region and pass the viewmodel as the datacontext. When we remove the view from the region the view is GC’d as expected however the viewmodel isn’t. The interesting thing is that if I pass the viewmodel to the view but not set it as the datacontext, both the view and viewmodel gets GC’d. I can’t think why this would be.<br /> <br />Anyway, I’m glad to see you are blogging more frequently.<br /><br />Cheers<br />IanAnonymousnoreply@blogger.com