Exemplo n.º 1
0
        /// <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();
        }
Exemplo n.º 2
0
 /// <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)
 {
 }
Exemplo n.º 3
0
 /// <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)
 {
 }
Exemplo n.º 4
0
 /// <summary>
 /// Allocate a new RecyclableMemoryStream object.
 /// </summary>
 /// <param name="memoryManager">The memory manager</param>
 public RecyclableMemoryStream(RecyclableMemoryStreamManager memoryManager)
     : this(memoryManager, null, 0, null)
 {
 }