title: R encoutered a fatal error and terminate; after I export 500GB data and can't read any files since then
body: <p>I tried to process batch of Himawari-8 data and export them to the tif files I want. The codes I used are as below:</p>
  <pre><code>library(raster)
  library(ncdf4)
  library(rgdal)
  library(DoParallel)
  library(foreach)
  
  lst &lt;- list.files(path=&quot;D:\\0619\\&quot;,pattern='nc$',full.names=TRUE)
  detectCores()
  
  usecores &lt;- detectCores-10
  cl &lt;- makeCluster(usecores)
  registerDoParallel(cl)
  
  foreach(i =1:143) %dopar% {
    library(raster)                                                                                                                                                                                                                                                                                                     
    library(ncdf4) 
    library(rgdal)
    nc&lt;-nc_open(lst[3])
    r1&lt;-raster(lst[i],
               var='albedo_01')
    r2&lt;-raster(lst[i],
               var='albedo_02')
    r3&lt;-raster(lst[i],
               var='albedo_03')
    r4&lt;-raster(lst[i],
               var='albedo_04')
    
    rg &lt;-0.6321*r2+0.2928*r3+0.0715*r4
    rr &lt;- brick(r3,rg,r1)
    name &lt;- strsplit(lst[i],&quot;\\_&quot;)
    tifname &lt;- paste(&quot;H8_VIS_&quot;,name[[1]][3], &quot;_&quot;,name[[1]][4],&quot;_FLDK&quot;,sep=&quot;&quot;)
    rw &lt;- writeRaster(rr,filename = paste(&quot;E:\\H8_VIS_data\\20190619\\&quot;, tifname, &quot;.tif&quot;, sep=&quot;&quot;),
                      format = 'GTiff')
  }
  stopCluster(cl)
  </code></pre>
  <p>This code works on my PC and export nearly 500GB data. One day, it went wrong and report error</p>
  <pre><code>R encoutered a fatal error
  The session was terminated
  </code></pre>
  <p>I looked for solutions, tried to uninstall R and RStudio, delete any R files I can find, restart PC and install R &amp; RStudio in conda.
  Then, it works for a well. After I process two H-8 netcdf data(600MB each). R crashed again and reported the same error.
  ####################################################################</p>
  <p>I thought it's my PC doesn't have enough RAM, so I run this on a very high performance computer. After about 500GB data are exported, R report a error:</p>
  <pre><code>error in unserialize(socklist[[n]]): error reading from connection
  </code></pre>
  <p>Then I stop to run code in parallel, after export two result, R crashed and show</p>
  <pre><code>R encoutered a fatal error
  The session was terminated
  </code></pre>
  <p>And the R on this high performance computer cannot work anymore. I used <code>gc()</code> and it doesn't work. I think during my data process, some garbage stored in somewhere and they exceed R's storage.</p>
  <p>Please tell me how to fix this problem. Thank you very much!</p>
  <p>#######</p>
  <p>I just find out that, read raster from a one file will not terminate.</p>
  <pre><code>r1 &lt;- raster(&quot;D:/0619/h8_201906190000.nc&quot;,var = 'albedo_1')
  </code></pre>
  <p>While reading files from a list will terminate. (I didn't call for parallelization this time. It just blowed up because of these two code.)</p>
  <pre><code>list &lt;- list.files(path=&quot;D:\\0619\\&quot;,pattern='nc$',full.names=TRUE)
  r1 &lt;- raster(list[1],var = 'albedo_1')
  </code></pre>