我得到這個錯誤,想不通爲什麼它正在發生而應用程序沒有使用多少內存
我使用Windows 8.1的64位32 GB的RAM內存
你怎麼能得到的System.OutOfMemoryException應用程序是32位,使用任務管理器時只有大約400 MB,更少的時候檢查與GC.GetTotalMemory(false)
如何調試此錯誤的原因?
C#WPF .NET 4.5應用
這裏最大壓縮字符串中的數據庫中的數據(322 KB):http://www.monstermmorpg.com/reciprocal/zipped.txt
該最大數據(4837 KB)的在這裏未壓縮字符串:http://www.monstermmorpg.com/reciprocal/unzipped.txt
這裏解壓字符串功能
private static string Un_GZip_String(string compressedText)
{
using (var memoryStream = new MemoryStream())
{
byte[] gZipBuffer = Convert.FromBase64String(compressedText);
int dataLength = BitConverter.ToInt32(gZipBuffer, 0);
memoryStream.Write(gZipBuffer, 4, gZipBuffer.Length - 4);
var buffer = new byte[dataLength];
memoryStream.Position = 0;
using (var gZipStream = new GZipStream(memoryStream, System.IO.Compression.CompressionMode.Decompress))
{
gZipStream.Read(buffer, 0, buffer.Length);
}
return Encoding.UTF8.GetString(buffer);
}
}
http://i.stack.imgur.com/fepMs.png
可能是DecompressString方法中的一個錯誤。進入它,看看它實際上拋出異常的線? – Quintium 2014-09-23 21:55:24
字符串有多大,未壓縮版本有多大? – 2014-09-23 21:55:28
@JonSkeet都很小。這裏解壓縮的字符串:http://pastebin.com/AGrabX2s - 解壓縮函數是gzip – MonsterMMORPG 2014-09-23 21:56:43