I have a great solution with graphics, pop-ups and animations. I found that while navigating the pages, I had a massive memory leak.
Is trying
So I tried with the first solution:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (App.RootFrame.CanGoBack)
App.RootFrame.RemoveBackEntry();
GC.Collect();
base.OnNavigatedTo(e);
}
From several sources in MSDN and Stackoverflow, the memory saved for this page should be deleted. This was not so, and I am not sure that the structure of the MVVM code somehow stores the information. Then I tried to implement deconstructors and force values equal to zero when the event was fired as follows:
~SecondScreen()
{
In_Game_Crest = null;
currentViewModel = null;
}
, . , . , IDisposable fiddeling viewmodelLocator, MVVMLight, - .
:
qaru.site/questions/1569714/...
/ #
MSDN:
MSDN: Finalize Dispose
, . Windows?
MVVM, ViewModel ?
Windows .
Dispose
, , , ? . , MSDN , :
private bool disposed = false;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if(!this.disposed)
{
if(disposing)
{
currentView = null;
popup = null;
Image1 = null;
Image2 = null;
}
this.Content = null;
}
disposed = true;
}
~FirstPage()
{
Dispose(false);
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
this.Dispose();
base.OnNavigatedFrom(e);
}
, 23 , . , , ?
this = null, base.Dispose()
, this = null base.Dispose(). , , IDisposable? ? , ?
Microsoft Profiler
, FirstPage
, . . :
, FirstPage . , ?
.