[Fwd: Re: [R] Memory leak in R v1.5.1?] - resolved

Jan Meyer janm at mit.edu
Wed Aug 7 14:51:11 CEST 2002


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:
  >>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
  >>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

More information about the R-help mailing list