This question is locked. New answers and comments are not allowed.
Hi,
I am writing a Silverlight navigational application using MVVM framework. I am using JustTrace to track memory leaks. Hence my post in this forum.
Scenario:
Now when I navigate away from the initial view to a new view, the new view's viewmodel also has a property which will be assigned the value from the static field in constructor.
But this time, in the memory snapshot, the second viewmodel's instance is retained and increments by one every time I visit this view.
In the memory snapshot, it shows that it still holds reference to the static field.
How do I release the reference to the static field so that the second viewmodel is garbage collected?
Hope I have explained enough.
Thanking you in advance.
I am writing a Silverlight navigational application using MVVM framework. I am using JustTrace to track memory leaks. Hence my post in this forum.
Scenario:
- I have a static Helper class which has a static property that refers to a class. i.e. if I have a class DefinedClass, the property is
- public static DefinedClass MyClass
- I am using this to store application variables that will be populated from different views using corresponding viewmodels.
- In the first view, I populate properties in MyClass. This is done using MyClass as one of the properties in viewmodel.
- On UnLoading, the property is set to null so that it does not hold the reference to the static class.
- This goes fine and I do not see any instance of the viewmodel in memory snapshot.
Now when I navigate away from the initial view to a new view, the new view's viewmodel also has a property which will be assigned the value from the static field in constructor.
- this view/viewmodel makes some changes and then navigates to the previous view.
- on UnLoading, again, MyClass is set to null to break any references to the static variable.
But this time, in the memory snapshot, the second viewmodel's instance is retained and increments by one every time I visit this view.
In the memory snapshot, it shows that it still holds reference to the static field.
How do I release the reference to the static field so that the second viewmodel is garbage collected?
Hope I have explained enough.
Thanking you in advance.