Jan 6, 2011 at 10:35 AM
Edited Jan 6, 2011 at 10:40 AM
Hi BladeWise, first thank for a help, And now I answers on your questions:
I think that your designer is pretty good regarding the caching part (re-create the view-model and push messages when needed), but I still have a dubt... are you using a view-first approach? I'm asking
since you wrote that you are storing opened chat windows in a dictionary.
I store reference on chat view models in dictionary with this reasons:
- Chat view model class is create as non shared because for every user I want own chat view model class and chat view.
- If I create chat view model class non shared I must ensure that for one user exist only one chat view model class.
You click on listbox item and create new chat view. You click again on same listbox item and it create another new chat view. This behavior I don’t want in my application. So if some chat view model is created I use dictionary on control
if this chat view is active/deactive. I create chat view models class only in situation if this class doesn’t exist.
That said, have you verified that the Deactivate method is called on window close?
Yes, I add debuger breakpoint in method OnDeactivate, this method is call if chat view is closing.
I double checked the WindowManager implementation (and expecially the WindowConductor one) and, except for a
probably incorrect behaviour in a rare case (i.e. if you deactivate the view-model without requesting a close, and then perform a real close from the view-model, such operation is ignored due to the fact that the event has
been detached), I could not spot an issue causing such a heavy memory leak.
How can I deactive view model with requesting a close? If you wish I can upload my application and you can try it and check if this problem is real. Have this problem some solution? I check Issue Tracker ->WindowManager+WindowConductor
possible incorrect detaching from Deactivated . If I override method void Deactivated(object sender, DeactivationEventArgs e) in WindowConductor in solve this problem? I have problem in caliburn micro find WindowConductor class :[
Have you tried forcing a
Yes, it doesn’t help decrease memory usage.
Finally, can I ask you how you identified the problem? Does your application try an OutOfMemoryException? Are you using a memory profiler? Or you just guessed that a problem is occurring since the application memory usage increases?
I use ANTS Memory profiler. Quick example. Chat view consist two bindable richteboxes with conversation ( text + smiles images).
I open chat view, publish some messages and close WPF window. Then I use ANTS Memory profiler and I see richtextboxes object are still alive. I suppose after I close view it also destroy UI controls in view
also object of chat view model is still alive.
I use simple logic. My chat view models are non shared, so my chat view are non shared (non singleton instaces). If I open chat view and then I close chat view. I don’t have instaces of this object in memory.
After I open/close chat screen 10 - 20 times memory is still increasing.