From: Damien Doligez <damien.doligez@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Weak pointers and Gc.finalise
Date: Thu, 1 Apr 2004 19:07:55 +0200 [thread overview]
Message-ID: <1E3A29A6-83FF-11D8-BD34-00039310CAE8@inria.fr> (raw)
In-Reply-To: <DB9719D9-8397-11D8-AAA7-003065BDAA76@ece.ucsb.edu>
On Apr 1, 2004, at 06:48, Shivkumar Chandrasekaran wrote:
> I just noticed that if the only reference to a bigarray is in a Weak.t
> array, and if there is a finalisation function set on the bigarray,
> then that finalisation function is not necessarily called when the
> entry in the Weak.t array is set to None. Rather it is potentially
> called *much* later.
That's right. Within a GC cycle, we first handle the weak pointers
that have to be erased, then we handle the finalised values.
> I am assuming that this is the right behaviour.
We have to do it that way because there might be several weak pointers
to the same value, and they have to be all erased before we call
the finalisation function.
> My question is, can I get the finalisation function to be called when
> the weak pointer is being set to None?
I guess it might be possible to attach functions to weak pointers,
to be called when the weak pointer is erased, but that would be
different from finalisation functions, and it would need a large
amount of work to modify the GC.
> (Side note: I am trying to avoid Marshaling the Bigarray unless it is
> going to be garbage-collected. But if I cannot detect that, then I
> have to always Marshal it whenever its entries change, which is very
> inefficient.)
I'm not sure I understand. The finalisation function is called when
the value is about to be garbage-collected. Why can't you just
marshal it at that point?
-- Damien
-------------------
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
next prev parent reply other threads:[~2004-04-01 17:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-01 4:48 Shivkumar Chandrasekaran
2004-04-01 17:07 ` Damien Doligez [this message]
2004-04-01 19:21 ` Shivkumar Chandrasekaran
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=1E3A29A6-83FF-11D8-BD34-00039310CAE8@inria.fr \
--to=damien.doligez@inria.fr \
--cc=caml-list@inria.fr \
/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