Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Karl Zilles <zilles@1969web.com>
To: Christopher Kauffman <kauffman@cs.umn.edu>
Cc: OCaml <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Trouble with Scanf and files
Date: Thu, 17 Jan 2008 17:39:58 -0800	[thread overview]
Message-ID: <4790036E.3000203@1969web.com> (raw)
In-Reply-To: <478FF82D.1070305@cs.umn.edu>

Christopher Kauffman wrote:
> I have encountered some difficulty using Scanf with a large number of
> files. As suggested in the the Ocaml manual, my strategy so far when
> reading a number of files has been to use Scanf.Scanning.from_file to
> create a scanbuf for each file. I had always wondered if this would
> cause problems with large numbers of files because I could not figure
> out a way to close a file after completing operations on it. Today I
> attempted to process too many and received a fatal system error. If one
> allocates a scanbuf via
 >
 > let b = Scanf.Scanning.from_file "somefile" in ...
 >
> is there a way to subsequently close the file when the buffer is no
> longer needed? Or is this an issue that should be taken care of by the
> garbage collector in some strange way?

The documentation doesn't seem to be very clear.  But, it would be 
unusual for Ocaml code to rely on the garbage collector to close file 
handles.

Perhaps this is obvious, but maybe

let ic = open_in "somefile" in
let b = Scanf.Scanning.from_channel ic in
...
close_in ic

would solve your problem.


  reply	other threads:[~2008-01-18  1:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-18  0:51 Christopher Kauffman
2008-01-18  1:39 ` Karl Zilles [this message]
2008-01-18  8:30 ` [Caml-list] " Olivier Andrieu
2008-01-18 23:12   ` Chris Kauffman

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=4790036E.3000203@1969web.com \
    --to=zilles@1969web.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=kauffman@cs.umn.edu \
    /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