问题
I use ionic zip (version-1.9.1.8) to compress some files..I usually have large files summing to 2 to 3 GB ...this ionic zip works fine in my system but while i use it in another user machine(ONSITE)...this ionic zip throws an exception as follows.The configuration of both the system are same.
Exception details:
******************
[6/11/2012 01:21:38:812]
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at Ionic.Zip.ZipEntry._WriteEntryData(Stream s)
at Ionic.Zip.ZipEntry.Write(Stream s)
at Ionic.Zip.ZipFile.Save()
at Ionic.Zip.ZipFile.Save(String fileName)
at MyCode.SaveZipFile()
[6/11/2012 01:21:38:828]
System.NullReferenceException: Object reference not set to an instance of an object.
at Ionic.Zlib.ParallelDeflateOutputStream._Flush(Boolean lastInput)
at Ionic.Zlib.ParallelDeflateOutputStream.Close()
at Ionic.Zlib.ParallelDeflateOutputStream.Dispose()
at Ionic.Zip.ZipFile.Dispose(Boolean disposeManagedResources)
at Ionic.Zip.ZipFile.Dispose()
at Mycode.SaveZipFile()
at Mycode.SaveLogs()
Could someone help me to find the cause of such issues..??
Thanks in advance
回答1:
You need to show the code. If your app is zipping into a memorystream, it will be susceptible to out-of-memory conditions. This would be a problem in your app, not in the library.
Also - I see from the stacktrace that it is using the parallel deflater. This trades runtime for memory. IF you have memory issues, you can disable parallel compression, and use much less memory.
Do this by something like this in your code:
zip.ParallelDeflateThreshold = -1;
also see the doc on this feature: http://cheeso.members.winisp.net/DotNetZipHelp/html/0988edb5-1d59-2875-8e77-ad195601cbce.htm
来源:https://stackoverflow.com/questions/10978786/ionic-zip-throws-out-of-memory-exception