4

As probably everyone else working with large data and limited memory, I often come across memory problems in R. These problems become manifest in the error message:

error: cannot allocate vector of size XYZ

which results, as all error messages, in the stop of the workflow; the requested operation has not been carried out.

and sometimes the warning message:

Warning: Reached total allocation of 8061Mb: see help(memory.size)

which, as all warning messages, does not interrupt the workflow; the requested operation has been carried out.

I wonder,

  1. Why do some memory-intense commands result in an error and others in a warning? I.e., what is the technical difference between these two?

  2. Are results trustworthy if the warning message has been issued?

csgillespie
  • 59,189
  • 14
  • 150
  • 185
mzuba
  • 1,226
  • 1
  • 16
  • 33
  • The error is documented [here](https://stat.ethz.ch/R-manual/R-patched/library/base/html/Memory-limits.html): "Error messages beginning `cannot allocate vector of size` indicate a failure to obtain memory, either because the size exceeded the address-space limit for a process or, more likely, because the system was unable to provide the memory." The relevant source for the warning is [here](https://github.com/wch/r-source/blob/fbf5cdf29d923395b537a9893f46af1aa75e38f3/src/gnuwin32/malloc.c#L1334-L1363). My naive read would be that you should take the warning seriously. – Thomas Mar 19 '15 at 12:09
  • 1
    I believe the warning is issued when R tries to continue and recover from the memory exhaustion (by running the garbage collector). Also see [this answer](http://stackoverflow.com/questions/15101045/r-memory-limit-warning-vs-unable-to-allocate). – Jerzy Mar 31 '16 at 13:11

0 Answers0