问题描述
嗨
我遇到了一个尚未解决的问题.我是否要一个接一个地在Image控件上连续加载图像..我将从服务器获取图像..它将连续发送图像..我必须连续显示它 在我的Windows Phone上..我正在获取最多30张图片,并且在显示该图片之后显示了"OutofMemory Exception"(例外),这是我在网站上浏览过的图片,并且发现了图像控件的内存释放.像这样.
i got one problem which was not resolved yet..that is i want to load images continously on Image control one after one ..i will get images from server..which will send the images continously..and i have to show it continously on my windows phone ..i am getting images upto 30 and it was displaying after that i am getting an exception is "OutofMemory Exception"..for that i have browsed in the websites and i find the memory release of image control..like this..
BitmapImage bitmap = Image1.source作为BitmapImage();
BitmapImage bitmap=Image1.source as BitmapImage();
bitmap.Urisource = null;
bitmap.Urisource=null;
Image1.source = null;
Image1.source=null;
即使我添加了上面的代码,也没有任何变化,并且我遇到了相同的异常..请帮助我.....
Even i added the above the code also there is no change and i am getting the same exception ..please help me out.....
谢谢
推荐答案
垃圾收集器释放该内存可能会有一段时间.
There may be a time lag for the Garbage Collector to release that memory.
为减少内存消耗,请确保每个图像的尺寸(以像素为x和y方向)保持尽可能小. JPG可以扩展以消耗大量内存.
To reduce memory consumption be sure the size of each image (x and y direction in pixels) is kept as low as possible. A JPG can expand to consume a LOT of memory.
还要检查您可能正在创建但未无效的其他对象.留意引用其他对象的对象,以防止后者被垃圾收集器释放.
Also check for other objects that you may be creating but not nullifying. Watch for objects that reference other objects, preventing the latter objects from being released by the garbage collector.
希望这会有所帮助,
标记
Hope this helps,
Mark
这篇关于连续加载图像时出现内存不足异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!