clear cache in window phone 7
I want Dipose cache in window phone 7. In my project I have download Images, after use I Dispose Image by:
Image.source = null;
Image = null;
but memory does not return to its original, for example:
After download I set source of image :
img.source = new bitmapImage(new uri("http://diadiem.com/image/123.jpg"),UriKind.Relative);
When next Page or LoadPage Again: I want clear item old item, and Replease memory in cache.
Although I tried set image.source= null
, and set control Image = null
. But memory does not r开发者_开发百科eturn to its original.
Please help me!
To remove a downloaded image from the cache you need to assign it's source to a separate BitmapImage
and set that to null before setting the image's source to null.
BitmapImage bitmapImage = image.Source as BitmapImage;
bitmapImage.UriSource = null;
image.Source = null;
Don't ask me why, but it works.
What you can do to enforce system to load image always from the URL is to use the following inception:
img.source = new bitmapImage(new uri("http://diadiem.com/image/123.jpg?random=" + randomvar)...
Where randomvar
is a random variable like GUID.NewGuid()
精彩评论