Buffer Pool

To reduce memory garbage production the plugin reuses as much memory as it can. To support this, the plugin implements and uses a byte array pooling mechanism through the BufferPool static class. The plugin uses this class to allocate and release byte[]s back to the pool.

To avoid keeping reference to too much memory the plugin requests buffers with a minimum size. This way if the BufferPool has no buffer for the requested size, it can return a larger buffer. Also, buffers stored in the pool can time out, releasing back to the runtime for garbage collection.

Pooling mechanism can be disabled, configured and used by outside of the plugin. Configurable fields are the following:

So to disable pooling the following line can be added:

BestHTTP.PlatformSupport.Memory.BufferPool.IsEnabled = false;

The following functions are available to use the pool: