Asp.net、.net 3.5、win2003、iis6.0を使用しています。
Oracleを使用してファイルを収集し、ファイルをSharpZipLib.BZip2圧縮形式でテーブルOracleのフィールドRAWに保存します。
私のアプリケーションはWebであり、ファイルのデータ(バイトの配列)を取得するためにWCFサービスを使用しています。aspxページはファイルをユーザーに送信します(ダウンロードファイル)。
私の問題-問題:
OracleからDATAを読み取りました(WCFサービスを呼び出します)。バイトの配列(byte [])を取得します。
SharpZipLib.BZip2を使用してファイルを解凍してみます
using (MemoryStream inData = new MemoryStream(data))
{
using (MemoryStream outData = new MemoryStream())
{
BZip2.Decompress(inData, outData); //<==================== Fails here OutOfMemoryException
return outData.ToArray();
}
}
エラーは、「非圧縮」ファイルが大きいため、非常に大きい(> 500 MB)ためです。
圧縮ファイル:4MB
非圧縮ファイル:> 500 MB
私はこのようにテストします:
BufferedStream bufin = new BufferedStream(instream);
using (MemoryStream outData = new MemoryStream())
{
BZip2.Decompress(bufin, outData);
return outData.ToArray();
}
しかし、私は同じOutOfMemoryExceptionを取得します
例外のトレーススタック
en System.IO.MemoryStream.set_Capacity(Int32 value)
en System.IO.MemoryStream.EnsureCapacity(Int32 value)
en System.IO.MemoryStream.WriteByte(Byte value)
en Reale.Frk.Compression.BZip2.BZip2.Decompress(Stream inStream, Stream outStream)
SharpZipLib.BZip2.Decompressのコード
public static void Decompress(Stream inStream, Stream outStream)
{
if ( inStream == null ) {
throw new ArgumentNullException("inStream");
}
if ( outStream == null ) {
throw new ArgumentNullException("outStream");
}
using ( outStream ) {
using ( BZip2InputStream bzis = new BZip2InputStream(inStream) ) {
int ch = bzis.ReadByte();
while (ch != -1) {
outStream.WriteByte((byte)ch);
ch = bzis.ReadByte();
}
}
}
}
提案、コメント、サンプルソースコードはありますか?