Hi, an attach() call turned out to be my problem (see below). Thanks everybody for the helpful comments. - Jan -------- Original Message -------- Subject: Re: [R] Memory leak in R v1.5.1? Date: Wed, 07 Aug 2002 01:12:09 -0400 From: Jan Meyer <janm at mit.edu> To: Peter Dalgaard BSA <p.dalgaard at biostat.ku.dk> References: <Pine.LNX.4.31.0208061713050.2645-100000 at gannet.stats> <3D4FFC7E.20205 at mit.edu> <x2znw0x6wg.fsf at biostat.ku.dk> Hi Peter, right on the point. I had an attach() statement in my function that I was calling frequently. Now after removing all attach() statements in frequently called functions, the problem is completely gone (except for an almost unnoticable increase in cons cells over time -- but that's not a problem). I still don't fully understand why attach caused the problem. Wouldn't attach just place some variables in the environment of the function, which is destroyed at the end of the function call? Thanks a lot for this great hint. - Jan Peter Dalgaard BSA wrote: > Jan Meyer <janm at mit.edu> writes: > > >>Hi, >> >>yes, I was using these low limit non-standard flags to start R: >> nice -n 5 R --min-vsize=10M --max-vsize=40M --min-nsize=500k >>--max-nsize=2M >> >>These settings were used to trigger the problem early rather than wait >>hours each time for testing. As I understand the limit max-nsize=2M >>translates into 2 million cells (not 2MB), which is equivalent with >>16MB VM. >> >>The problem occured first running R without memory limits on a Linux >>box with 128 MB phys. RAM, which at some point (~ 10 hours after >>starting the script) was swapping like crazy and hardly doing any >>calculations anymore. The size of the whole process had grown from >>24MB to over 100MB. I find that this is a noticable amount. >> >>What in my code could trigger this excessive cons cell growth? > > > It's anybody's guess but you might unwittingly be accumulating memory > somewhere. Stuff like putting attach() inside a function and then > calling the function many times has that kind of consequences. That > usually conks out fairly quickly though... > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Peter Dalgaard BSA
2002-Aug-07 17:10 UTC
[Fwd: Re: [R] Memory leak in R v1.5.1?] - resolved
Jan Meyer <janm at mit.edu> writes:> Hi, > > an attach() call turned out to be my problem (see below). > > Thanks everybody for the helpful comments. >...> I still don't fully understand why attach caused the problem. Wouldn't > attach just place some variables in the environment of the function, > which is destroyed at the end of the function call?No, attach() adds things to the search path (and logically, although not always physically, copies them). This is not reversed when the function exits. [It is not obvious that it has to work that way, but currently it does.] -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._