I got a long list of error message repeating with the following 3
lines when running the loop at the end of this mail:
R(580,0xa000ed88) malloc: *** vm_allocate(size=327680) failed (error
code=3)
R(580,0xa000ed88) malloc: *** error: can't allocate region
R(580,0xa000ed88) malloc: *** set a breakpoint in szone_error to debug
There are 2 big arrays, IData (54x64x50x504) and Stat (4x64x50x9), in
the code. They would only use about 0.8GB of memory. However when I
check the memory usage during the looping, the memory usage keeps
growing and finally reaches the memory limit of my computer, 4GB, and
spills the above error message.
Is there something in the loop about lme that is causing memory
leaking? How can I clean up the memory usage in the loop?
Thank you very much for your help,
Gang
============
tag <- 0; dimx<-54; dimy<-64; dimz<-50; NoF<-8; NoFile<-504;
IData <- array(data=NA, dim=c(dimx, dimy, dimz, NoFile));
Stat <- array(data=NA, dim=c(dimx, dimy, dimz, NoF));
for (i in 1:NoFile) {
IData[,,,i] <- fill in the data for array IData here;
}
for (i in 1:dimx) {
for (j in 1:dimy) {
for (k in 1:dimz) {
for (m in 1:NoFile) {
Model$Beta[m] <- IData[i, j, k, m];
}
try(fit.lme <- lme(Beta ~ group*session*difficulty+FTND, random =
~1|Subj, Model), tag <- 1);
if (tag != 1) {
Stat[i, j, k,] <- anova(fit.lme)$F[-1];
}
else {
Stat[i, j, k,] <- rep(0, NoF-1);
}
tag <- 0;
}
}
}
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.