This project is read-only.
1
Vote

Disposing of ViewModels

description

Hello Sacha,

we are heavy-using your really great CinchV2.
But over the last week we ran into problems.
It seems like ViewModels are not correctly disposed, or I am completely wrong…

The Situation:
  • I wrote a small Application (attached), with a MainView which has to display different views inside a ContentControl (or whatever)
  • When you start the program, one view (UserControl1) is loaded inside this ContentControl => This view has a ViewModel called ViewModel1
  • When you click “next”, the UserControl1 is disposed (correctly), but not the ViewModel1
  • When you switch multiple times between these two views, every time the views is correctly disposed, but ONE instance of ViewModel1 is always staying.
There are no references to the viewmodel, which prevent to GC to collect this instance. The ViewModel is NOT marked as “Shared” it is explicitly NONSHARED.

I double-proofed with dotMemory from Jetbrains (a really great tool for such purposes). dotMemory showed me also, that your small DemoApplication from Cinch is closing the AboutViewModel correctly, when I close the AboutView with “x”.

Am I wrong, that the ViewModel should be disposed or am I doing something wrong?

Can you please be so kind to help me, or give me a small advice where I can look further?

Greetings

Tobias

file attachments

comments

heilmannseder wrote Jun 1, 2015 at 7:34 AM

This "problem" also exists in the Cinch Demo.
  1. Start the Demo
  2. Click "About"
  3. Close "About"
    Look with dotMemory, and there is the AboutViewModel. Even after long time waiting and waiting for GC.