[R] Garbage Collecting

Kjetil Kjernsmo kjetil.kjernsmo at astro.uio.no
Fri Jul 14 20:19:53 CEST 2000


Hello again! I have some follow-up on the problem I had with the garbage
collector. I have finally come across a computer with > version
         _                
platform i686-pc-linux-gnu
arch     i686             
os       linux-gnu        
system   i686, linux-gnu  
status                    
major    1                
minor    1.0              
year     2000             
month    June             
day      15               
language R                
(I believe it is running RH6.2, and it has 128MB RAM). It seems I am able
to reproduce the problem I had on this system as well, with exactly the
same objects that I had on the alpha. The objects (all that are needed
to reproduce the problem) are in
<URL:http://www.astro.uio.no/~kjetikj/tmp/kjetil.RData> (file is 87457
bytes), and the basic thing I am doing, is that I am passing a largish
object between functions a lot of times.

The function calls gc(v=T) for every time it is called (by an, I realize, 
ineffective apply-call), and the output looks like this  
> l4 <- t(apply(cbind(rep(1000000, 4)), 1, lineprofile, 1, 80, 
+                 smap01n$histogram))
Garbage collection [nr. 1]...
193062 cons cells free (55%)
25145 Kbytes of heap free (98%)
Garbage collection [nr. 4]...
191545 cons cells free (54%)
19217 Kbytes of heap free (75%)
Garbage collection [nr. 8]...
190029 cons cells free (54%)
13290 Kbytes of heap free (52%)
Garbage collection [nr. 14]...
188513 cons cells free (53%)
7362 Kbytes of heap free (29%)
> l4 <- t(apply(cbind(rep(1000000, 4)), 1, lineprofile, 1, 80, 
+                 smap01n$histogram))
Garbage collection [nr. 28]...
187005 cons cells free (53%)
1438 Kbytes of heap free (6%)
Error: heap memory (25600 Kb) exhausted [needed 45 Kb more]
       See "help(Memory)" on how to increase the heap size.
> gc()
         free   total (Mb)
Ncells 186764  350000  6.7
Vcells  11446 3276800 25.0

It seem something like 6 MB goes for each call. I started R with
vsize=25M, which is the least one needs to do the run once. 

I have also tried on a sparc-sun-solaris2.7 box with apparently the same
results.

Now, there is always a possibility that I have some really strange things
in my code, or that my understanding of the garbage collector is totally
flawed. I have tried to come up with a minimal piece of code needed to
reproduce the problem, but I have so far failed, I continue to try.
Meanwhile, I hope the code I have put on the web can shed some light... 
:-)

The other problem I had with disappearing values has been resolved, thanks
to Brad McNeney.

Best,

Kjetil
-- 
Kjetil Kjernsmo
Graduate astronomy-student                    Problems worthy of attack
University of Oslo, Norway            Prove their worth by hitting back
E-mail: kjetikj at astro.uio.no                                - Piet Hein
Homepage <URL:http://www.astro.uio.no/~kjetikj/>
Webmaster at skepsis.no 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list