title: "Cannot allocate vector of size xxx mb" error, nothing seems to fix
body: <p>I'm running RStudio x64 on Windows 10 with 16GB of RAM. RStudio seems to be running out of memory for allocating large vectors, in this case a 265MB one. I've gone through multiple tests and checks to identify the problem:</p>
  
  <ol>
  <li>Memory limit checks via <code>memory.limit()</code> and <code>memory.size()</code>. Memory limit is ~16GB and size of objects stored in environment is ~5.6GB. </li>
  <li>Garbage collection via <code>gc()</code>. This removes some 100s of MBs.</li>
  <li>Upped priority of rsession.exe and rstudio.exe via Task Manager to real-time.</li>
  <li>Ran <code>chkdsk</code> and RAM diagnostics on system restart. Both returned no errors.</li>
  </ol>
  
  <p>But the problem persists. It seems to me that R can access 16GB of RAM (and shows 16GB committed on Resource Monitor), but somehow is still unable to make a large vector. My main confusion is this: the problem only begins appearing if I run code on multiple datasets consecutively, without restarting RStudio in between. If I do restart RStudio, the problem doesn't show up anymore, not for a few runs.</p>
  
  <p>The error should be replicable with any large R vector allocation (see e.g. the code <a href="https://stackoverflow.com/questions/5171593/r-memory-management-cannot-allocate-vector-of-size-n-mb">here</a>). I'm guessing the fault is software, some kind of memory leak, but I'm not sure where or how, or how to automate a fix.</p>
  
  <p>Any thoughts? What have I missed?</p>