[Rd] stopping finalizers
Antonio, Fabio Di Narzo
antonio.fabio at gmail.com
Thu Feb 14 20:22:45 CET 2013
I'm not sure I got your problem right, but you can keep a named copy
of your not-to-be-finalized object as long as it needs to be around,
so it doesn't go out of scope too early.
dontFinalizeMe <- obj
## code which creates copies, overwrites, and indirectly uses 'obj'
Antonio, Fabio Di Narzo,
Mount Sinai School of Medicine, NY.
2013/2/12 Thomas Lumley <tlumley at uw.edu>:
> Is there some way to prevent finalizers running during a section of code?
> I have a package that includes R objects linked to database tables. To
> maintain the call-by-value semantics, tables are copied rather than
> modified, and the extra tables are removed by finalizers during garbage
> However, if the garbage collection occurs in the middle of processing
> another SQL query (which is relatively likely, since that's where the
> memory allocations are) there are problems with the database interface.
> Since the guarantees for the finalizer are "at most once, not before the
> object is out of scope" it seems harmless to be able to prevent finalizers
> from running during a particular code block, but I can't see any way to do
> Thomas Lumley
> Professor of Biostatistics
> University of Auckland
> [[alternative HTML version deleted]]
> R-devel at r-project.org mailing list
More information about the R-devel