Welcome to the Xceed Community Sign in | Join | Help
Community Search  

An unhandled exception of type 'System.OutOfMemoryException' occurred in xceed.compression.dll

Sort Posts: Previous Next
  •  07-11-2008, 6:25 PM Post no. 13532

    An unhandled exception of type 'System.OutOfMemoryException' occurred in xceed.compression.dll

    Hi

    I have been using CompressedStream as part of web service with out any problem until it tried to decompress large amount of data (more than 300 MB), The error message is 'System.OutOfMemoryException'

     Is there any way around it? If I do not use CompressedStream, it runs ok ...

    Thanks

     

  •  07-15-2008, 3:16 PM Post no. 13567 in reply to 13532

    Re: An unhandled exception of type 'System.OutOfMemoryException' occurred in xceed.compression.dll

    Do you decompress data directly to disk or in a MemoryStream? If you decompress in a MemoryStream, the decompress data will go directly into RAM memory and can cause this exception.

     

    Is this the compressed or decompressed size?  If it is the compressed size, and the compression ratio is high, then the decompression size can be much bigger, exceeding the available memory, explaining the memory exception.


    André
    Software Developer and Tech Support
    Xceed Software Inc.
  •  07-18-2008, 11:57 AM Post no. 13629 in reply to 13567

    Re: An unhandled exception of type 'System.OutOfMemoryException' occurred in xceed.compression.dll

    The response stream from the http request is passed to CompressedStream (see codes below). Then, the CompressedStream decompresses it to the disk. So, I'm not sure how I can decompress data to disk directly (please advise).

    The size is the decompressd size.

    WebRequest wReq = WebRequest.Create(http://hello.com);
    wReq.Timeout = Timeout.Infinite;
    WebResponse wRes = wReq.GetResponse();
    Stream stream = wRes.GetResponseStream();
    Xceed.Compression.Licenser.LicenseKey = "ZIN10-EBAUD-ZZZZ";
    CompressedStream compStream =
    new CompressedStream( stream );

     

    FileStream fs;
    fs =
    new FileStream(destination,FileMode.Create);
    byte[] buffer = new byte[32768];
    int bytesRead=0;

    while( ( bytesRead = compStream.Read( buffer, 0, buffer.Length ) ) > 0 ){
    fs.Write (buffer, 0, bytesRead);
    fs.Flush();
    }
    fs.Flush();
    fs.Close();
    compStream.Close();
    //automatically close stream

  •  07-18-2008, 2:41 PM Post no. 13631 in reply to 13629

    Re: An unhandled exception of type 'System.OutOfMemoryException' occurred in xceed.compression.dll

    Your code seems fine, that's what we had in mind.  This should work if the system resources are enough.

    You could try to wrap a .NET stream around the response stream, just to see if you get the same exception.  This would indicate the problem is not with CompressedStream.  You can try with BufferedStream or DeflateStream.

     


    André
    Software Developer and Tech Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.