Browse thread
[Caml-list] GC and file descriptors
-
Dustin Sallings
- David Fox
- Nicolas George
- Mikael Brockman
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2003-11-15 (15:56) |
From: | Ville-Pertti Keinonen <will@e...> |
Subject: | Re: [Caml-list] GC and file descriptors |
On Sun, Nov 16, 2003 at 01:16:08AM +1100, skaller wrote: > It is possible to modify the Ocaml collector to make finalisation > orderly, but it is very expensive. It is also possible Not just expensive, more like something you definitely don't want to even try. Python tries to have deterministic finalization, but falls back on "normal" garbage collection for containers (with potential cyclic references). Perl doesn't even bother with that, instead it doesn't resolve cyclic references at all. Typically, the best you can do is explicit finalization; which can be convenient using something similar to Lisp with-open-file constructs, possibly with alternate interfaces and finalization on GC as a fallback for poorly structured programs. For more complicated cases with multiple references, what you probably want is an explicit liveness count (separate from the GC/memory references). The liveness count can likewise be protected by something similar to unwind-protect blocks. Considering that OCaml doesn't have capturable continuations, things are relatively simple. ------------------- 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