嘿。当用户单击这样的项目时,我正在从独立存储中读取图像:
using (IsolatedStorageFile currentIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
using (var img = currentIsolatedStorage.OpenFile(fileName, FileMode.Open))
{
byte[] buffer = new byte[img.Length];
imgStream = new MemoryStream(buffer);
//read the imagestream into the byte array
int read;
while ((read = img.Read(buffer, 0, buffer.Length)) > 0)
{
img.Write(buffer, 0, read);
}
img.Close();
}
}
这很好用,但是如果我在两个图像之间来回单击,内存消耗会不断增加,然后内存不足。有没有更有效的方式从独立存储中读取图像?我可以在内存中缓存几张图片,但有数百个结果,最终还是会占用内存。有什么建议么?