Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET OutOfMemory exception using .net compact zip with WriteXml

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #20052 |

    In our software, I have the following code:

                            Xceed.Zip.ZippedFile testFile = new ZippedFile(new DiskFile(myDirectory + “Backup\\testdiff”), “testdiff.txt”);
                            ZipArchive archive = (ZipArchive)testFile.RootFolder;
                            archive.DefaultEncryptionPassword = EncryptionKey;
                            archive.DefaultCompressionMethod = Xceed.Compression.CompressionMethod.Deflated64;
                            archive.DefaultCompressionLevel = Xceed.Compression.CompressionLevel.Highest;
                            Stream tempStream = null;

                            if (File.Exists(myDirectory + “Backup\\testdiff”))
                            {
                                // open the file for writing
                                tempStream = testFile.OpenWrite(true,
                                                   FileShare.None,
                                                   Xceed.Compression.CompressionMethod.Deflated64,
                                                   Xceed.Compression.CompressionLevel.Highest,
                                                   EncryptionKey);
                            }
                            else
                            {
                                tempStream = testFile.CreateWrite(FileShare.None);
                            }

                            XmlTextWriter myWriter = new XmlTextWriter(tempStream, System.Text.Encoding.ASCII);
                            testDataDiff.WriteXml(myWriter, System.Data.XmlWriteMode.IgnoreSchema);
                            myWriter.Close();

    This code works fine about 99% of the time. However, 1% of the time, it gives this exception:

     

    System.OutOfMemoryException: OutOfMemoryException

    at
    Xceed.Compression.CompressionEngine.Managed.XDeflate.DeflateInit()

    at
    Xceed.Compression.ManagedDeflateCompressor..ctor()

    at
    Xceed.Compression.ManagedDeflate64Compressor..ctor()

    at
    Xceed.Compression.CompressedStream.Write()

    at
    Xceed.Utils.Streams.NotifyStream.Write()

    at
    System.IO.StreamWriter.Flush()

    at
    System.IO.StreamWriter.Write()

    at
    System.Xml.XmlTextWriter.InternalWriteEndElement()

    at
    System.Xml.XmlTextWriter.WriteEndElement()

    at
    System.Data.DataTextWriter.WriteEndElement()

    at
    System.Data.XmlDataTreeWriter.XmlDataRowWriter()

    at
    System.Data.XmlDataTreeWriter.Save()

    at
    System.Data.DataSet.WriteXml()

    at
    EpocHost.DataManager.WriteTestDataDiff()

     

    I don’t really see how it can be out of memory as my program allocates memory before and after this and everything runs fine.The file in question isn’t even that big.. unzipped it is a few kilobytes at the most.

    Any help would be appreciated.

    Taha

    Imported from legacy forums. Posted by Ahmed (had 1658 views)

    Xceed Support
    Member
    Post count: 5658

    Hi,

    you can try to flush the content of the DefaultTempFolder after each operation. Moreover, could you send us  an application that reproduces this issue, at support@xceed.com? This will greatly help us identifying and resolving it. 

    Imported from legacy forums. Posted by Mohamed [Xceed] (had 1670 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.