It’s a phone, limited memory bla2

There are leaks everywhere, but let’s try to minimize it

01. Panorama Background image
The first culprit is panorama background image

if(panorama.Background is ImageBrush)
(panorama.Background as ImageBrush).ImageSource=null;
//do this before you set any new imageBrush

02. NavigationService.BackStack
Keep in mind sometimes you don’t want to clear it…

//clear the last one only...

03. Reactive extension IDisposeable
Don’t forget to dispose it

04. Storyboard, SoundEffectInstance

05. Disposeable Task…

06. Image, ImageBrush, BitmapImage (basically same as number 1, null source stuff)

07. Events anonymous method

Thanks to sransom

I did try to not using anonymous method and my memory get reduced !

//do this and you get memory leak !

08. Call GC.Collect() on the right time

09. set panorama to null

//do when you don't want to navigate anymore...
this.Unloaded += new RoutedEventHandler(Page_Unloaded)

void DashboardPage_Unloaded(object sender, RoutedEventArgs e)
this.Unloaded -= new RoutedEventHandler(Page_Unloaded);
panorama=null; // save 4-5 mb yea ! memory usage around 15 mb

10. Implement disposeable and dispose your page
a. panorama hub –> b. setting page –> c. panorama hub

when you are on b, you can’t destroy a yet due you want to support back navigation
dispose a once you move forward to c