title: How to resolve error: cannot allocate vector of size 70.7 Gb in RStudio?
body: <p>I need to convert .nc file (size 35 GB) to .csv. It is showing an error saying : cannot allocate vector of size 70.7 Gb</p>
  
  <p>How to resolve this error?</p>
  
  <p>I have successfully converted .nc files (size 4 kb) to .csv files using the same code that I am using to convert larger files.</p>
  
  <p>I tried to clear the memory using gc() command before nc.df... command. Also, I tried to increase memory limit as below.</p>
  
  <pre><code>              &gt; memory.limit()
                [1] 16306
  
                &gt; memory.limit(size = 120000)
                [1] 120000
  </code></pre>
  
  <p>The code is as follows:</p>
  
  <pre><code>   &gt; rm(list = ls())
     &gt; library(raster)
     &gt; nc.brick &lt;- brick(file.choose())
     &gt; nc.df &lt;- as.data.frame(nc.brick, xy=T)
     &gt; write.csv(nc.df, file.choose())
  </code></pre>
  
  <p>The expected result is to get a .csv file using the above code. However, presently, after second last command (i.e.,  nc.df &lt;- as.data.frame(nc.brick, xy=T), it gives the said error i.e., Error: cannot allocate vector of size 70.7 Gb.</p>
  
  <pre><code>&gt; sessionInfo()
  R version 3.4.0 (2017-04-21)
  Platform: x86_64-w64-mingw32/x64 (64-bit)
  Running under: Windows &gt;= 8 x64 (build 9200) 
  
  Matrix products: default 
  
  locale: 
  [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 
  [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C 
  [5] LC_TIME=English_United States.
  
  1252 attached base packages: 
  [1] stats graphics grDevices utils datasets methods base 
  
  other attached packages: 
  [1] raster_2.5-8 sp_1.2-4 RevoUtilsMath_10.0.0 
  
  loaded via a namespace (and not attached): 
  [1] compiler_3.4.0 RevoUtils_10.0.4 rgdal_1.2-7 tools_3.4.0 Rcpp_0.12.10 ncdf4_1.16
  [7] grid_3.4.0 lattice_0.20-35
  </code></pre>
  
  <p>I tried library ff but it is again giving the same error.</p>
  
  <pre><code>            &gt; rm(list = ls())
              &gt; library(ff)
              &gt; nc.brick &lt;- brick(file.choose())
              &gt; nc.df &lt;- as.data.frame(nc.brick, xy=T) 
  </code></pre>