using System; using System.Buffers; class Program { static void Main() { // Allocate a memory pool with 1 GB capacity var pool = MemoryPoolIn this example, a memory pool with 1 GB capacity is created using the `MemoryPool.Shared; var buffer = pool.Rent(1024 * 1024 * 1024); try { // Use the buffer by creating a memory span var memory = buffer.Memory; // Fill the memory with data for (int i = 0; i < memory.Length; i++) { memory.Span[i] = (byte)(i % 256); } } finally { // Return the buffer to the pool when done pool.Return(buffer); } } }