2
Vote

Remove GC.Collect() or make it optional

description

There are two places in library where GC.Collect() is called affecting application performance.

We use SevenZipSharp in an multithreaded application that extracts and processes thousands of files (332 zip archives with 193387 text files in test run) and aggregates information on them, as a result we have quite a bit of objects in memory by the end of the run and garbage collector spend more and more time to enumerate all of them. The degradation is very significant because while garbage collector doing its job all other threads are waiting.

Commenting out GC.Collect() altogether with GC.WaitForPendingFinalizers() reduced run time (with 6 worker threads) from more then 2 hours to less then 9 minutes! I didn't noticed any significant difference in memory usage by application.

Commenting out GC.AddRemoveMemoryPressure() and GC.RemoveMemoryPressure() gave another 30-45 seconds bust so run time reduced to 8 minutes.

comments