title: Is it possible to create smaller memory-mapped views on a 2GB+ file?
body: <p>I have written a C++ class for Windows and Linux that creates a memory-mapped view for an file of arbitrary size n. The code for the class constructor <a href="http://pastebin.com/2GX0XHsm" rel="nofollow">can be seen here</a>. I am currently testing the code on Windows 32 bit XP. </p>
  
  <p>I have found for file sizes 0 &lt; n &lt;= 1.7GB , the constructor returns a valid pointer to a memory-mapped view. However, for a file size >= 2 GB, MapViewOfFile returns a NULL value and an error code of 8, "Not enough storage is available to process this command". Evidently, Windows cannot find an available address space of size 2 GB in the process.</p>
  
  <p>Therefore, I may need to modify the class constructor to create a set of smaller memory-mapped views totaling >= 2GB bytes &amp;&amp; &lt; 2 ^ 32 - 1 bytes. The other requirement is to create a mapping between each of the smaller memory-mapped views and a randomly accessed address in the  process' address space.</p>
  
  <p>Previously, I used the following code for random access:    </p>
  
  <pre><code>char* KeyArray;
  
  try {
      mmapFile = new cMemoryMappedFile(n);
  }
  catch (cException e)
  {
      throw;
  }
  
  KeyArray = (char *)(mmapFile-&gt;GetPointer());
  KeyArray[i] = ...
  </code></pre>
  
  <p>How should I modify the class to handle these requirements?</p>