Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Ask for a more efficient way to deallocate memory (full version)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-12-10 (20:27)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] Ask for a more efficient way to deallocate memory (full version)
On Mon, Dec 10, 2007 at 05:33:21PM +0100, Oliver Bandel wrote:
> Zitat von Fabrice Pardo <>:
> [...]
> > When using these kind of external C functions,
> > OCaml seems then less comfortable to the programmer
> > than reference counted languages.
> I doubt that reference-count is the reason here.
> perl also uses reference count, but Filehandles
> and Dirhandles have to be closed with close / closedir.

This isn't true.  In Perl file handles are closed at the end of a
scope if they are no longer used.  In other words a Perl-equivalent to
this loop will never use more than a single file descriptor:

  while (true) {
    open "foo"

Even in a GC'd language which could finalize the file handle you could
never be sure when the GC is going to be called so it could use an
indefinite number of file descriptors.

There is a really good paper on this subject -- how ref counting and
garbage collection are orthogonal language concepts -- but I can't
find it right now.


Richard Jones
Red Hat