Hi all,
In a simulation context, I'm applying some my function, "myfun" say, to a
list of glm obj, "list.glm":
length(list.glm) #number of samples simulated
class(list.glm[[324]]) #any component of the list
length(list.glm[[290]]$y) #sample size
[1] 1000
Because length(list.glm) and the sample size are rather large, I've splitted
the list into 10 sub-list, say: list.glm1, list.glm2,....
Now I'm using of course:
out1<-lapply(list.glm1, myfun)
out2<-lapply(list.glm2, myfun)
....
However only the first works, for the second one it is:
Error: cannot allocate vector of size 3 Kb
In addition: Warning message:
Reached total allocation of 255Mb: see help(memory.size)
So I increase the memory
out2<-lapply(list.glm2, myfun) #works
out3<-lapply(list.glm3, myfun) #does not works
Error: cannot allocate vector of size 31 Kb
In addition: Warning message:
Reached total allocation of 300Mb: see help(memory.size)
Again I increase the memory.size
out3<-lapply(list.glm3, myfun) #works!
out4<-lapply(list.glm4, myfun) #does not work!
.....
So it seems I have to increase the memory.size each time before applying my
function. This is suprising because I know that returning to the prompt the
memory is fully available again. So being the lists similar, why the same
memory size is not sufficient for every list?