2
Vote

Memory leak in Animated image

description

On Windows Phone 7, I noticed the animatedimage control was not getting unloaded due to the timer not being stopped (forcing the control to stay in memory).
 
In the constructor add..
 
        this.Unloaded += new RoutedEventHandler(AnimatedImage_Unloaded);
 
    void AnimatedImage_Unloaded(object sender, RoutedEventArgs e)
    {
        Stop();
    }
 
That will stop the timer and force the control to be unloaded when it is no longer in use.
Cheers!

comments

zaxbowow wrote Sep 30, 2012 at 8:48 PM

This was a big clue to solving my issue, thanks.

For an ExtendedImage using the GifDecoder, be VERY SURE to call <ThisImage>.Stop in the navigation event leaving the page on which it is placed. Otherwise "Out of Memory" errors can/will occur on subsequent visits to that page.

wrote Feb 21, 2013 at 11:53 PM

wrote Jun 8, 2015 at 11:22 AM