make x:Bind memory clean in UWP
Some tips here:
1. If memory has PropertyChangedHandler left, make sure the list does not have any item.
2. Call Page.Bindings.StopTracking() in Page_Unloaded event
3. If you use x:Bind with MvvmLight, and using RelayCommand, you need to set RelayCommand enity to null in Page_Unloaded.
4. For checking the page is completely released, use the launch mouse recorder to open page and back multiple times. It is important to ensure every PageBack&GC cleared all no used memories.
=============Important Update=============
Don’t use Bindings.StopTracking()! When switch pages quickly, some xaml components would not be released!
Use
1 |
SimpleIoc.Default.Unregister<ViewModel>(key); |
Instead