我正在創建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