title: Allocating Max Memory in R
body: <p>I got the following error message in R relating to memory:</p>
  <pre><code>Error: cannot allocate vector of size 7.5 Gb
  </code></pre>
  <p>I was reading that there are ways in R/R Studio to allocate more memory compared to what is currently available.</p>
  <p>I tried using the following command, but got the following error:</p>
  <pre><code>&gt; memory.limit(size=2500)
  [1] 7831
  Warning message:
  In memory.limit(size = 2500) : cannot decrease memory limit: ignored
  </code></pre>
  <p>I tried to find out how much I currently have:</p>
  <pre><code>get_free_ram &lt;- function(){
      if(Sys.info()[[&quot;sysname&quot;]] == &quot;Windows&quot;){
          x &lt;- system2(&quot;wmic&quot;, args =  &quot;OS get FreePhysicalMemory /Value&quot;, stdout = TRUE)
          x &lt;- x[grepl(&quot;FreePhysicalMemory&quot;, x)]
          x &lt;- gsub(&quot;FreePhysicalMemory=&quot;, &quot;&quot;, x, fixed = TRUE)
          x &lt;- gsub(&quot;\r&quot;, &quot;&quot;, x, fixed = TRUE)
          as.integer(x)
      } else {
          stop(&quot;Only supported on Windows OS&quot;)
      }
  }
  </code></pre>
  <p>I also tried this:</p>
  <pre><code>&gt; get_free_ram()
  [1] 323076
  
  &gt; gc()
             used  (Mb) gc trigger (Mb)   max used   (Mb)
  Ncells  2038194 108.9    6346452  339    7933065  423.7
  Vcells 14755424 112.6  975825445 7445 1015087309 7744.6
  </code></pre>
  <ul>
  <li><strong>In short : I understand there is a limit - but is there some way in R to allocate the max amount of memory/RAM that your computer is able to do?</strong></li>
  </ul>
  <p>Thank you!</p>
  <pre><code>#Further Notes:
  
  &gt; sessionInfo()
  R version 4.1.3 (2022-03-10)
  Platform: x86_64-w64-mingw32/x64 (64-bit)
  Running under: Windows 10 x64 (build 22000)
  
  Matrix products: default
  
  locale:
  [1] LC_COLLATE=English_Canada.1252  LC_CTYPE=English_Canada.1252    LC_MONETARY=English_Canada.1252 LC_NUMERIC=C                   
  [5] LC_TIME=English_Canada.1252 
  </code></pre>