BufferSize Property

DotNetZip

Ionic Zip Library v1.9.1.6 BufferSize Property
ReferenceIonic.ZlibParallelDeflateOutputStreamBufferSize
The size of the buffers used by the compressor threads.
Declaration Syntax
C# Visual Basic Visual C++
public int BufferSize { get; set; }
Public Property BufferSize As Integer
	Get
	Set
public:
property int BufferSize {
	int get ();
	void set (int value);
}
Remarks

The default buffer size is 128k. The application can set this value at any time, but it is effective only before the first Write().

Larger buffer sizes implies larger memory consumption but allows more efficient compression. Using smaller buffer sizes consumes less memory but may result in less effective compression. For example, using the default buffer size of 128k, the compression delivered is within 1% of the compression delivered by the single-threaded DeflateStream. On the other hand, using a BufferSize of 8k can result in a compressed data stream that is 5% larger than that delivered by the single-threaded DeflateStream. Excessively small buffer sizes can also cause the speed of the ParallelDeflateOutputStream to drop, because of larger thread scheduling overhead dealing with many many small buffers.

The total amount of storage space allocated for buffering will be (N*S*2), where N is the number of buffer pairs, and S is the size of each buffer (this property). There are 2 buffers used by the compressor, one for input and one for output. By default, DotNetZip allocates 4 buffer pairs per CPU core, so if your machine has 4 cores, then the number of buffer pairs used will be 16. If you accept the default value of this property, 128k, then the ParallelDeflateOutputStream will use 16 * 2 * 128kb of buffer memory in total, or 4mb, in blocks of 128kb. If you set this property to 64kb, then the number will be 16 * 2 * 64kb of buffer memory, or 2mb.

Assembly: Ionic.Zip (Module: Ionic.Zip) Version: 1.9.1.8 (1.9.1.8)