我正在创建Windows Phone 8应用程序,我有一个带有512 MB RAM的Windows Phone 8,当我在模拟器上运行应用程序时,它运行得非常好,但是当我检查Windows电话8设备,我得到例外Windows Phone 8中的System.OutOfMemoryException
System.OutOfMemoryException
当仍然有很多可用内存。 看到我的代码如下:
private IsolatedStorageFileStream isoVideoFile;
string isoVideoFileName = "Movie.mp4";
using (isoVideoFile = new IsolatedStorageFileStream(isoVideoFileName,
FileMode.OpenOrCreate, FileAccess.ReadWrite,
IsolatedStorageFile.GetUserStoreForApplication()))
{
using (MemoryStream stream = new MemoryStream())
{
isoVideoFile.Write(stream.GetBuffer(), 0, (int)stream.Position);
}
byte[] binaryData = new Byte[isoVideoFile.Length];
long bytesRead = isoVideoFile.Read(binaryData, 0, (int)isoVideoFile.Length);
string videofile = Convert.ToBase64String(binaryData, 0, binaryData.Length);
}
你真的想把所有的文件内容放到内存中吗?你不能通过块来转换文件块吗? –
是的。 VIDEO文件假定有一个视频文件。它有多大?我强烈建议不要像这样读取它 - 使用较小的缓冲区(512kb),并按大块移动块。 – TomTom
您的设备具有x空闲MB的事实并不意味着您可以实际分配x MB。有这种东西叫做内存碎片。此外,有可能是每个应用程序的限制。 – dandan78