title: OutOfMemoryException using BZip2 (SharpZipLib)
body: <p>I use Asp.net , .net 3.5, win2003, iis 6.0. </p>
  
  <p>I use Oracle for gathering files, saving file in SharpZipLib.BZip2 compressed format in field RAW in table Oracle.</p>
  
  <p>My application is Web, and I use WCF Service for get data (array of bytes) of a file. The aspx page send file to user (download file).</p>
  
  <p>My issue-problem: </p>
  
  <p>I read DATA from Oracle, (I call to WCF Service). I get array of bytes (byte[]), </p>
  
  <p>I try Uncompress file using SharpZipLib.BZip2</p>
  
  <pre><code>using (MemoryStream inData = new MemoryStream(data))
  { 
  using (MemoryStream outData = new MemoryStream())
  {
            BZip2.Decompress(inData, outData); //&lt;==================== Fails here OutOfMemoryException
            return outData.ToArray();
  }
  
  }
  </code></pre>
  
  <p>the error is because the file "uncompressed" is big, very big (> 500 MB) !!!</p>
  
  <p>compressed file: 4MB</p>
  
  <p>uncompressed file: > 500 MB</p>
  
  <p>I do test like this:</p>
  
  <pre><code>BufferedStream bufin = new BufferedStream(instream);
  
              using (MemoryStream outData = new MemoryStream())
              {
                  BZip2.Decompress(bufin, outData);
  
                  return outData.ToArray();
              }
  </code></pre>
  
  <p>But I get the same OutOfMemoryException</p>
  
  <p>Trace Stack of Exception</p>
  
  <pre><code>   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)
  </code></pre>
  
  <p>Code of SharpZipLib.BZip2.Decompress</p>
  
  <pre><code>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();
  
                               }
  
                          }
  
                    }
  
              }
  </code></pre>
  
  <p>any suggestions, comments, sample source code ?</p>