title: MemoryMappedFile - IOException: The paging file is too small for this operation to complete
body: <p>Hi I've got a problem with a .net process that's throwing the following exception when creating a memory mapped file,</p>
  
  <pre><code>System.IO.IOException: The paging file is too small for this operation to complete.
  at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
  at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateCore(SafeFileHandle fileHandle, String mapName, HandleInheritability inheritability, MemoryMappedFileSecurity memoryMappedFileSecurity, MemoryMappedFileAccess access, MemoryMappedFileOptions options, Int64 capacity)
  at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateNew(String mapName, Int64 capacity, MemoryMappedFileAccess access, MemoryMappedFileOptions options, MemoryMappedFileSecurity memoryMappedFileSecurity, HandleInheritability inheritability)
  </code></pre>
  
  <p>I've still got a lot of Ram available according to task manager and when it happens my process is at about 3G on a box with 15G of Ram.</p>
  
  <p>My Process is creating and destroying hundreds of these memory mapped files a minute on multiple threads.</p>
  
  <p>Is there some kind of limit I'm running into that I'm not aware of?</p>
  
  <p>My class that's throwing the exception appears to dispose of the memory correctly, it's always in a using statement</p>
  
  <pre><code>internal unsafe class VirtuallyBackedMemory : IDisposable
  {
      private readonly MemoryMappedViewAccessor _accessor;
      private readonly MemoryMappedFile _file;
  
      public VirtuallyBackedMemory(string name, long sizeInBytes)
      {
          _file = MemoryMappedFile.CreateNew(name,sizeInBytes, MemoryMappedFileAccess.ReadWrite);
  
          _accessor = _file.CreateViewAccessor(0, sizeInBytes, MemoryMappedFileAccess.ReadWrite);
  
          BaseAddress = _accessor.Pointer(0);
      }
  
      public byte* BaseAddress { get; }
  
      ~VirtuallyBackedMemory()
      {
          Dispose(false);
      }
  
      public void Dispose()
      {
          Dispose(true);
  
          GC.SuppressFinalize(this);
      }
  
      protected virtual void Dispose(bool disposing)
      {
          if (disposing)
          {
              if (_accessor != null)
              {
                  if (BaseAddress != null)
                      _accessor.SafeMemoryMappedViewHandle.ReleasePointer();
  
                  _accessor.Dispose();
              }
  
              if (_file != null)
                  _file.Dispose();
          }
      }
  }
  </code></pre>