[R] Is there a way to detect when gc() is called?
hb at maths.lth.se
Mon Nov 12 19:29:15 CET 2001
A finalizer feature is really great. However, currently this is actually
more than I need. I only need to know when the garbage collector is started,
not what object it is removing. In other words, I would like to have
function myGC(...) called *automatically* when the memory is running low,
almost like a onLowMemory="myGC()".
> -----Original Message-----
> From: Thomas Lumley [mailto:tlumley at u.washington.edu]
> Sent: Monday, November 12, 2001 7:20 PM
> To: Henrik Bengtsson
> Cc: r-help at stat.math.ethz.ch
> Subject: Re: [R] Is there a way to detect when gc() is called?
> On Mon, 12 Nov 2001, Henrik Bengtsson wrote:
> > I would like to run a method, which removes obsolete/redundant
> data in my
> > data structures, when gc() will/is/has been called. In other
> words, is it
> > possible to make the garbage collector to trig another function?
> There is a finalizer mechanism now in R. I don't know if the documentation
> at http://developer.r-project.org is completely up to date, but it should
> show you were to look (mostly in memory.c)
> Finalizers don't quite do what you want, because it is very difficult.
> It turns out to be impractical to guarantee that every finalizer is run
> exactly once. Languages have to choose between running it at least once
> and at most once. As I understand it (Luke Tierney is the authority) R
> follows Java in ensuring that the finalizer is run at most once, but some
> objects that are removable may never be removed.
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