public MemoryBlockCollection Allocate(int size) { List<Memory<byte>> blocks = new List<Memory<byte>>(); WriteAdvance(size); while (size > 0) { IBuffer buffer = GetWriteBuffer(); Memory<byte> item = buffer.AllocateMemory(size); blocks.Add(item); size -= item.Length; if (size == 0) break; } return new MemoryBlockCollection(blocks); }