我想在 window phone 7 中使用 Dipose 缓存。在我的项目中,我下载了图像,使用后我通过以下方式处理图像:
Image.source = null;
Image = null;
但内存并没有回到原来的样子,例如:
下载后我设置图片来源:
img.source = new bitmapImage(new uri("http://diadiem.com/image/123.jpg"),UriKind.Relative);
当下一个页面或再次加载页面时:我想要清除项目旧项目,并在缓存中补充内存。
虽然我尝试设置 image.source= null
,并设置控件 Image = null
。但内存并没有回到原来的样子。
请帮帮我!
最佳答案
要从缓存中删除下载的图像,您需要将其源分配给单独的 BitmapImage
并将其设置为 null,然后再将图像的源设置为 null。
BitmapImage bitmapImage = image.Source as BitmapImage;
bitmapImage.UriSource = null;
image.Source = null;
不要问我为什么,但它确实有效。
关于windows-phone-7 - 清除window phone 7中的缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7062820/