From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Chris Hecker <checker@d6.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] faq? gc'd channels & finalize?
Date: Mon, 19 Mar 2001 11:49:38 +0100 [thread overview]
Message-ID: <20010319114938.B30440@pauillac.inria.fr> (raw)
In-Reply-To: <4.3.2.7.2.20010318184951.02c6ace0@shell16.ba.best.com>; from checker@d6.com on Sun, Mar 18, 2001 at 06:58:20PM -0800
> File handles (channels) are not closed on garbage collection, right
> (my tests indicate they're not)?
This is correct.
> Why is this (just because no
> guarantees can be made on when objects will be finalized)?
That's one reason. Another reason is that when you have a low-level
file descriptor (Unix.file_descr) and build a channel around it
(Unix.{in,out}_channel_of_descr), it is often the case that you don't
want the file descriptor to be closed when the channel becomes garbage
collected -- your code may still be using the file descriptor.
> The docs
> warn against using finalization routines, so it seems like manually
> doing it (or using a wrapper function, which then has to catch and
> reraise exceptions) is the only way.
I'm not sure which part of the doc you're referring to, but with the
new per-object finalization facility of OCaml 3, I think it is safe
to do
Gc.finalise close_out my_out_channel
or
Gc.finalise close_in my_in_channel
for the channels you'd like to see finalized.
- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
prev parent reply other threads:[~2001-03-19 10:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-03-19 2:58 Chris Hecker
2001-03-19 10:49 ` Xavier Leroy [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20010319114938.B30440@pauillac.inria.fr \
--to=xavier.leroy@inria.fr \
--cc=caml-list@inria.fr \
--cc=checker@d6.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox