From luke-tierney at uiowa.edu  Thu Feb 14 12:53:10 2013
From: luke-tierney at uiowa.edu (luke-tierney at uiowa.edu)
Date: Thu, 14 Feb 2013 05:53:10 -0600
Subject: [Rd] stopping finalizers
In-Reply-To: <CAJ55+dJogFHu3bXBFSjDGynsH0FKN4A15=5uWg_KS4XTaEOSCA@mail.gmail.com>
References: <CAJ55+dJogFHu3bXBFSjDGynsH0FKN4A15=5uWg_KS4XTaEOSCA@mail.gmail.com>
Message-ID: <alpine.DEB.2.02.1302140544570.17940@luke-Latitude>

It might help if you could be more specific about what the issue is --
if they are out of scope why does it matter whether the finalizers
run?

Generically two approaches I can think of:

     you keep track of whenit is safe to fully run your finalizers and have
     your finalizers put the objects on a linked list if it isn't safe to
     run the finalizer now and clear the list each time you make a new one

     keep track of your objects with a weak list andturn them into strong
     references before your calls, then drop the list after.

I'm pretty sure we don't have a mechanism for temporarily suspending
running the finalizers but it is probably fairly easy to add if that
is the only option.

I might be able to think of other options with more details on the
issue.

Best,

luke

On Tue, 12 Feb 2013, Thomas Lumley wrote:

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

-- 
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:   luke-tierney at uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



[Rd] stopping finalizers
luke-tierney at uiowa.edu