Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Markus Mottl" <markus.mottl@gmail.com>
To: "Alain Frisch" <alain@frisch.fr>
Cc: "Loup Vaillant" <loup.vaillant@gmail.com>,
	"Caml mailing list" <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] The GC is not collecting... my mistake?
Date: Wed, 7 Nov 2007 10:36:55 -0500	[thread overview]
Message-ID: <f8560b80711070736p4ffa1361k74d289436d62c7d7@mail.gmail.com> (raw)
In-Reply-To: <473188A3.4010809@frisch.fr>

On 11/7/07, Alain Frisch <alain@frisch.fr> wrote:
> The safe assumption is that a value
> identifier forces the value to remain live in all its syntactic scope
> (this is not a formal definition; for instance, a tail call terminates
> the scope of identifiers defined at the call site).

The situation is actually even worse than that, e.g.:

  let _, b = expr in
  ...

In the case above the first element of the tuple and the tuple itself
that "expr" evaluate to will remain live until "b" is accessed even
though they are not bound to names.  This is certainly very
unintuitive behavior.  One would at least expect that values that
never get bound and aren't reachable through other bound values aren't
considered live.

> I agree this might be surprising, but since I don't see the behavior
> changing for bytecode anyway, I don't think it is worth dealing with
> this case in native code (any program that relies on the improved
> behavior you ask for would have an unexpected behavior in bytecode).

At least what concerns us we are not overly concerned about optimal
behavior in byte code, because everybody that cares about performance
(also memory-wise) uses native code anyway.  I personally wouldn't
mind if byte code behaved differently wrt. GC-behavior.

> The proper solution might be to reflect in the syntactic scope your
> desire to see some value reclaimed:

True, but this quickly becomes cumbersome, and the user may easily
forget to do it in all places.  Space leaks are generally extremely
hard to spot.

It seems like an easy thing to do to implement the intuitive notion
that a bound variable is considered live in an expression if it occurs
freely in this expression.  This is still not perfect, because
liveness analysis is generally undecidable.  But it surely comes close
to the heuristics that humans probably use to reason about liveness in
their code and would thus not violate their expectations.

Regards,
Markus

-- 
Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com


      reply	other threads:[~2007-11-07 15:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-06 12:51 Loup Vaillant
2007-11-06 14:46 ` [Caml-list] " Dominique Martinet
2007-11-06 17:31 ` Markus Mottl
2007-11-07  9:13   ` Loup Vaillant
2007-11-07  9:42   ` Alain Frisch
2007-11-07 15:36     ` Markus Mottl [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=f8560b80711070736p4ffa1361k74d289436d62c7d7@mail.gmail.com \
    --to=markus.mottl@gmail.com \
    --cc=alain@frisch.fr \
    --cc=caml-list@yquem.inria.fr \
    --cc=loup.vaillant@gmail.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