English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Understanding GC and Alarms
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-08-05 (14:33)
From: Damien Doligez <damien.doligez@i...>
Subject: Re: [Caml-list] Understanding GC and Alarms

On 2009-08-04, at 15:39, Björn Pelzer wrote:

> With the alarm loop, the GC will only print the first part ("Calling  
> finalisation functions.") once at the start of the loop and then  
> begin looping, starting new cycles but no new finalisations.

Yes, the GC calls the finalisation functions in order, so it waits for  
finalisation function to finish before starting the next one.  If your
function doesn't terminate...

> The other (and to me more severe) oddity is that if the alarm  
> function raises an exception, then the GC seems to remain in its  
> "special mode" where it starts no finalisation calling - but now it  
> will also refuse to do any alarms.

Yes, that is the essence of bug report 4742:
< http://caml.inria.fr/mantis/view.php?id=4742 >

> Is there a way to get the GC back to normal after an exception  
> during the alarm?

That is the purpose of the Gc.finalise_release function: tell the GC  
to behave
as if the current finalisation function had finished.  Note that  
is also safe to call from outside a finalisation function, so you can  
call it
from your exception handler.

When bug 4742 is fixed (probably in 3.12.0), you won't need it any more.
Note that I wanted to fix it by ignoring the exception entirely, but
your use case made me change my mind.

-- Damien