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.
-thomas
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._