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
[Caml-list] finalisers, Weak pointers
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-08-09 (09:31)
From: John Hale <hale@j...>
Subject: [Caml-list] finalisers, Weak pointers
Hi, does there exist any way to ensure that finalisers registered via 
the (undocumented) Gc.finalise
are called in order of their registration?

I have a program that deals in data structures that are collectively too 
big to all fit in main memory at once, and so I'd like to allow the 
garbage collector to decide when to write them out to disk files by
	(1) storing them in an array of Weak pointers
	(2) attaching finalisers who linearize the contents of array cells 
using the Marshal module.

as Damien Doligez writes in the stdlib/gc.mli,
>    A number of pitfalls are associated with finalised values:
>    finalisation functions are called asynchronously, sometimes
>    even during the execution of other finalisation functions.

(cf. http://caml.inria.fr/archives/200001/msg00011.html)

what I'm finding is that the finalisers sometimes get called in wacky 
orders such that `older' occupants
of the Weak array overwrite (on disk) what should be the current 
occupants. Is this just the "asynchronous" nature of the finalisers?

Is there any way to implement this kind of weak-pointer, disk-based 
backing store without having to "write-through" each time? In my 
particular case the data structures are variable-length so it seems only 
right that it be the Gc's decision whether they are too big to keep 

To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners