From antonio.fabio at gmail.com  Thu Feb 14 20:22:45 2013
From: antonio.fabio at gmail.com (Antonio, Fabio Di Narzo)
Date: Thu, 14 Feb 2013 14:22:45 -0500
Subject: [Rd] stopping finalizers
In-Reply-To: <CAJ55+dJogFHu3bXBFSjDGynsH0FKN4A15=5uWg_KS4XTaEOSCA@mail.gmail.com>
References: <CAJ55+dJogFHu3bXBFSjDGynsH0FKN4A15=5uWg_KS4XTaEOSCA@mail.gmail.com>
Message-ID: <CANyxDDcrU4VDE6hZCxmcPQm0UkVDVMEscyCzGvRgsNhAQqWPTg@mail.gmail.com>

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.

Something like:
local({
   dontFinalizeMe <- obj
   ##
   ## code which creates copies, overwrites, and indirectly uses 'obj'
   ##
})

hth,
--
Antonio, Fabio Di Narzo,
Biostatistician
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
> collection.
>
> 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
> it.
>
> Suggestions?
>
>     -thomas
>
>
> --
> Thomas Lumley
> Professor of Biostatistics
> University of Auckland
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] stopping finalizers
Antonio, Fabio Di Narzo