title: Why is MemoryPool slower and allocates more than ArrayPool?
body: <p>I'm not entirely sure if I have done something wrong in my tests, but from my results MemoryPool is consistently slower and allocates more memory than ArrayPool, since you can convert Array type to Memory anyway, what is the point of using MemoryPool?</p>
  <pre><code>using System.Buffers;
  using BenchmarkDotNet.Running;
  using BenchmarkDotNet.Attributes;
  
  BenchmarkRunner.Run&lt;test&gt;();
  
  [MemoryDiagnoser]
  public class test
  {
      [Benchmark]
      public void WithArrayPool()
      {
          ArrayPool&lt;int&gt; pool = ArrayPool&lt;int&gt;.Shared;
  
          for (int z = 0; z &lt; 100; z++)
          {
              var memory = pool.Rent(2347);
              
              for (int i = 0; i &lt; memory.Length; i++)
              {
                  memory[i] = i + 1;
              }
  
              int total = 0;
  
              for (int i = 0; i &lt; memory.Length; i++)
              {
                  total += memory[i];
              }
  
              pool.Return(memory);
          }
      }
  
      [Benchmark]
      public void WithMemoryPool()
      {
          MemoryPool&lt;int&gt; pool = MemoryPool&lt;int&gt;.Shared;
  
          for (int z = 0; z &lt; 100; z++)
          {
              var rentedArray = pool.Rent(2347);
              var memory = rentedArray.Memory;
              
              for (int i = 0; i &lt; memory.Length; i++)
              {
                  memory.Span[i] = i + 1;
              }
  
              int total = 0;
  
              for (int i = 0; i &lt; memory.Length; i++)
              {
                  total += memory.Span[i];
              }
  
              rentedArray.Dispose();
          }
      }
  }
  </code></pre>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Method</th>
  <th style="text-align: right;">Mean</th>
  <th style="text-align: right;">Error</th>
  <th style="text-align: right;">StdDev</th>
  <th style="text-align: right;">Allocated</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>WithArrayPool</td>
  <td style="text-align: right;">770.2 us</td>
  <td style="text-align: right;">2.27 us</td>
  <td style="text-align: right;">2.01 us</td>
  <td style="text-align: right;">1 B</td>
  </tr>
  <tr>
  <td>WithMemoryPool</td>
  <td style="text-align: right;">1,714.6 us</td>
  <td style="text-align: right;">0.56 us</td>
  <td style="text-align: right;">0.50 us</td>
  <td style="text-align: right;">2,402 B</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>My test code with results is above. Is Memory Pool actually just slower in general or is there something I am missing? If MemoryPool is in fact slower, what use case does it have?</p>
  <p>Thanks.</p>