Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R memory limit warning vs "unable to allocate..."

Tags:

r

Does a memory warning affect my R analysis?

When running a large data analysis script in R I get a warning something like:

In '... ' reached total allocation of ___Mb: see help...

But my script continues without error, just the warning. With other data sets I get an error something like:

Error: cannot allocate vector of size ___Mb:

I know the error breaks my data analysis, but is there anything wrong with just getting the warning? I have not noticed anything missing in my data set but it is very large and I have no good means to check everything. I am at 18000Mb allocated to memory and cannot reasonably allocate more.

like image 882
GregS Avatar asked Feb 26 '13 22:02

GregS


People also ask

What happens when malloc Cannot find a large enough block of memory to allocate?

malloc returns a void pointer to the allocated space, or NULL if there is insufficient memory available. To return a pointer to a type other than void , use a type cast on the return value.

What is the memory limit in R?

Under most 64-bit versions of Windows the limit for a 32-bit build of R is 4Gb: for the oldest ones it is 2Gb. The limit for a 64-bit build of R (imposed by the OS) is 8Tb.

How do I set memory limit in R?

Use memory. limit() . You can increase the default using this command, memory. limit(size=2500) , where the size is in MB.


1 Answers

Way back in the R 2.5.1 news I found this reference to memory allocation warnings:

malloc.c has been updated to version 2.8.3. This version has a slightly different allocation strategy, and is likely to work a little better close to address space limits but may give more warnings about reaching the total allocation before successfully allocating.

Based on this note, I hypothesize (without any advanced knowledge of the inner implementation) that the warning is given when the memory allocation call in R (malloc.c) failed an attempt to allocate memory. Multiple attempts are made to allocate memory, possibly using different methods, and possibly with calls to the garbage collector. Only when malloc is fairly certain that the allocation cannot be made will it return an error.

Warnings do not compromise existing R objects. They just inform the user that R is nearing the limits of computer memory.

(I hope a more knowledgeable user can confirm this...)

like image 190
Blue Magister Avatar answered Oct 26 '22 13:10

Blue Magister