Manages pools of RecyclableMemoryStream objects.
There are two pools managed in here. The small pool contains same-sized buffers that are handed to streams as they write more data. For scenarios that need to call GetBuffer(), the large pool contains buffers of various sizes, all multiples of LargeBufferMultiple (1 MB by default). They are split by size to avoid overly-wasteful buffer usage. There should be far fewer 8 MB buffers than 1 MB buffers, for example.
        /// <summary>
        /// Allocate a new RecyclableMemoryStream object
        /// </summary>
        /// <param name="memoryManager">The memory manager</param>
        /// <param name="tag">A string identifying this stream for logging and debugging purposes</param>
        /// <param name="requestedSize">The initial requested size to prevent future allocations</param>
        /// <param name="initialLargeBuffer">An initial buffer to use. This buffer will be owned by the stream and returned to the memory manager upon Dispose.</param>
        internal RecyclableMemoryStream(RecyclableMemoryStreamManager memoryManager, string tag, int requestedSize,
                                      byte[] initialLargeBuffer)
        {
            this.memoryManager = memoryManager;
            this.id = Guid.NewGuid();
            this.tag = tag;

            if (requestedSize < memoryManager.BlockSize)
            {
                requestedSize = memoryManager.BlockSize;
            }

            if (initialLargeBuffer == null)
            {
                this.EnsureCapacity(requestedSize);
            }
            else
            {
                this.largeBuffer = initialLargeBuffer;
            }

            this.disposed = false;

            if (this.memoryManager.GenerateCallStacks)
            {
                this.allocationStack = PclExport.Instance.GetStackTrace();
            }

            Events.Write.MemoryStreamCreated(this.id, this.tag, requestedSize);
            this.memoryManager.ReportStreamCreated();
        }
 /// <summary>
 /// Allocate a new RecyclableMemoryStream object
 /// </summary>
 /// <param name="memoryManager">The memory manager</param>
 /// <param name="tag">A string identifying this stream for logging and debugging purposes</param>
 public RecyclableMemoryStream(RecyclableMemoryStreamManager memoryManager, string tag)
     : this(memoryManager, tag, 0, null)
 {
 }
 /// <summary>
 /// Allocate a new RecyclableMemoryStream object
 /// </summary>
 /// <param name="memoryManager">The memory manager</param>
 /// <param name="tag">A string identifying this stream for logging and debugging purposes</param>
 /// <param name="requestedSize">The initial requested size to prevent future allocations</param>
 public RecyclableMemoryStream(RecyclableMemoryStreamManager memoryManager, string tag, int requestedSize)
     : this(memoryManager, tag, requestedSize, null)
 {
 }
 /// <summary>
 /// Allocate a new RecyclableMemoryStream object.
 /// </summary>
 /// <param name="memoryManager">The memory manager</param>
 public RecyclableMemoryStream(RecyclableMemoryStreamManager memoryManager)
     : this(memoryManager, null, 0, null)
 {
 }