caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] finalisers, Weak pointers
@ 2002-08-08 14:09 John Hale
  0 siblings, 0 replies; only message in thread
From: John Hale @ 2002-08-08 14:09 UTC (permalink / raw)
  To: caml-list

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
and
	(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 
in-core.

thanks,
-john
-------------------
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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-08-09  9:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-08 14:09 [Caml-list] finalisers, Weak pointers John Hale

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).