[R] "cannot allocate vector of size ..." in RHLE5 PAE kernel

Hugo Mildenberger Hugo.Mildenberger at web.de
Wed Jan 19 14:14:41 CET 2011


Dear Mauricio,

what I do not understand at all is the message:

> Error: cannot allocate vector of size 476.2 Mb

Have you tried to allocate a big matrix in between, whith
the R - statement not being shown in the output? Probably
not. If not, your local R version is buggy for sure. The test shows 
that the OS imposes no artificial constraint on memory consumption, 
at least not up to ~ 1GB. But because you said that you're running a
32 - bit version of R (in a virtual machine?), the question is now 
wether gcc also compiles the test program as a 32 - bit program. I'm 
unsure because a 64 - bit system can be configured to compile and 
run programs using either environment. Regrettably I previously
did not include a test for that. 

--- snip ---
#include <stdio.h>
int main() {
        printf("The size of a pointer is %lu bytes\n", (unsigned long)sizeof(void *));
        return 0;
}
--- snip ---

If the program says "The size of a pointer is 4 bytes" then you're 
running the test program in a 32 bit environment.  Then the 
allocation problem could possibly be solved by recompiling/updating 
your R version. The system is called Redhat "Enterprise" Linux after
all, so  calling in Redhat support at that point and ask them to do 
something for their money should be an option.

Best 

Hugo



On Wednesday 19 January 2011 12:54:38 Mauricio Zambrano wrote:
> Dear Hugo,
> 
> I tried your memory test program (without further modifications) just
> after the gc() command:
> 
> print(gc())
> print(gcinfo(TRUE))
> system("/mypath/memorytest.out")
> 
> and the result that I got was:
> 
> Number of simulations read from ' Particles.txt ' : 9000
> -------------------------------------------------------------------
>           used (Mb) gc trigger  (Mb)  max used   (Mb)
> Ncells  480114 12.9    1816453  48.6   5543382  148.1
> Vcells 5256970 40.2  119171871 909.3 322607910 2461.4
> [1] TRUE
> Trying to allocate 1000000000 bytes ... success. Now trying to commit
> memory ... succeeded.
> Garbage collection 2667 = 2286+194+187 (level 2) ...
> 12.9 Mbytes of cons cells used (26%)
> 278.4 Mbytes of vectors used (29%)
> Error: cannot allocate vector of size 476.2 Mb
> 
> What do you understand of this result ?
> 
> Thanks in advance,
> 
> Mauricio
> 
> >> I got the following warning:
> >>   memorytest.c: In function ‘main’:
> >>   memorytest.c:5: warning: return type of ‘main’ is not ‘int’
> >> Is this important ?
> >
> > Hello Mauricio,
> >
> > No, your gcc version is unduly puristic here. The traditional return
> > type of the main function in "C" should be "int", and if that is given,
> > main has to return an integer number explicitly. By convention,
> > a main function returning 0 indicates success, and anything other
> > is considered as an error or warning condition. Specifying "void main()"
> > normally implies returning zero. But if you are still worried simply
> > change "void main" into "int main()" and add the statement " return 0; "
> > just before the last curly bracket (without quotation marks, of course):
> >
> >  int main() {
> >       [...]
> >       return 0;
> > }
> >
> > Best
> >
> > Hugo
> >
> 



More information about the R-help mailing list