title: Who maps files to memory if I do not use MemoryMappedFile
body: <p>I had to work with lists of objects like they are in memory, but all data is persisted on disk. Something like memory mapped files, but instead I decided to make some wrapper which implements <code>IList</code>, but all functions just read/write file stream. i.e (locks/etc code is skipped)</p>
  
  <pre><code>public DiskMappedList(string directory)
  {
      _count = 0;
  
      if (!Directory.Exists(directory))
      {
          Directory.CreateDirectory(directory);
      }
      string fileName = Guid.NewGuid().ToString();
      _fileStreamHandle = File.Create(Path.Combine(directory, fileName));
      ProtoBuf.Serializer.PrepareSerializer&lt;T&gt;();
  }
  
  public void Add(T item)
  {
          ProtoBuf.Serializer.SerializeWithLengthPrefix(_fileStreamHandle, item, _lengthPrefix, _fieldNum);
          _fileStreamHandle.Flush();
          _count++;
  }
  </code></pre>
  
  <p>Notice that I use simple <code>FileStream</code> which is open by <code>File.Open</code> and that stream is closed only when object is removed from memory. </p>
  
  <p>Despite fact that only handle resides in memory I see high memory usage. RamMap shows that a big portion of files is "Memory mapped file". 
  So the question is - if I do not use MMF api and file is loaded into memory only when I call <code>ToList()</code>, which is pretty rare, who maps all my files to memory? Or may be "Memory mapped files" region is not for MMF only? Or may be <code>FileStream</code> uses MMF internally? Why I see several Gb memory usage?</p>
  
  <p>PS: Some screenshots
  <a href="https://i.stack.imgur.com/qbjRV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qbjRV.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/BpXS6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BpXS6.png" alt="enter image description here"></a></p>