[Rd] Need for garbage collection after creating object
Iago Mosqueira
iago.mosqueira at gmail.com
Tue Feb 5 17:01:18 CET 2008
Hello,
After experiencing some difficulties with large arrays, I was surprised
to see the apparent need for class to gc() after creating fairly large
arrays. For example, calling
a<-array(2, dim=c(10,10,10,10,10,100))
makes the memory usage of a fresh session of R jump from 13.8 Mb to
166.4 Mb. A call to gc() brought it down to 90.8 Mb,
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 132619 3.6 350000 9.4 350000 9.4
Vcells 10086440 77.0 21335887 162.8 20086792 153.3
as expected by
> object.size(a)
[1] 80000136
Do I need to call gc() after creating every large array, or can I setup
the system to do this more often or efficiently?
Thanks very much,
Iago
$platform
[1] "i686-pc-linux-gnu"
$version.string
[1] "R version 2.6.1 (2007-11-26)"
More information about the R-devel
mailing list