From: Damien Doligez <damien.doligez@inria.fr>
To: Paolo Donadeo <p.donadeo@gmail.com>
Cc: OCaml mailing list <caml-list@yquem.inria.fr>,
OCaml-Lua devel ML <ocaml-lua-devel@lists.forge.ocamlcore.org>
Subject: Re: [Caml-list] C binding and GC interaction: storing values outside the heap
Date: Wed, 8 Sep 2010 00:53:39 +0200 [thread overview]
Message-ID: <8DF23B0B-D2D5-45CE-99B1-37EA0C8BD4C6@inria.fr> (raw)
In-Reply-To: <AANLkTi=VCN4+wpKYG_EWUNX5zsBAs5_G_1hb2Y3uJDsu@mail.gmail.com>
On 2010-09-07, at 22:58, Paolo Donadeo wrote:
> The problem is that, for several good reasons, I need a copy, or a reference, to the OCaml value representing the lua_State (v_L in the code above) inside the Lua state (I mean the C data structure).
That creates a cross-heap reference loop and it's very bad news for the GC.
> As a temporary workaround I removed the "value state_value" field from the ocaml_data struct, replacing it with a reference counter:
Maybe you could try something similar, with a weak hash table to recover the
OCaml value corresponding to a given lua_State, thus eliminating the need for
a reference counter. Use the address of the lua_State for hashing and for
comparison.
Drawback: the weak hash table has to be global.
-- Damien
next prev parent reply other threads:[~2010-09-07 22:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-07 20:58 Paolo Donadeo
2010-09-07 21:12 ` [Caml-list] " Stéphane Glondu
2010-09-07 21:23 ` Paolo Donadeo
2010-09-07 21:48 ` Stéphane Glondu
2010-09-09 8:11 ` Paolo Donadeo
2010-09-07 22:53 ` Damien Doligez [this message]
2010-09-09 8:16 ` Paolo Donadeo
2010-09-08 5:06 ` Romain Beauxis
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=8DF23B0B-D2D5-45CE-99B1-37EA0C8BD4C6@inria.fr \
--to=damien.doligez@inria.fr \
--cc=caml-list@yquem.inria.fr \
--cc=ocaml-lua-devel@lists.forge.ocamlcore.org \
--cc=p.donadeo@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