caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Goswin von Brederlow <goswin-v-b@web.de>
To: Ocaml Mailing List <caml-list@inria.fr>
Subject: [Caml-list] wrapper for C++ class never gets garbage collected
Date: Mon, 7 Mar 2016 21:31:38 +0100	[thread overview]
Message-ID: <20160307203138.GA15388@frosties> (raw)

Hi,

I've run into a snag writing bindings for Qt5 widgets. The problem is
that GUI elements are never garbage collected.

Here is why:

The Qt5 object needs a pointer to the coresponding ocaml class so it
can deliver events that are generated by Qt5 to the ocaml side. It
therefore must have a "value ml_obj;". Because the GC can move the
ocaml object around that value must be registered as root with the GC.
The ocaml class then can never be garbage collected. And if it is not
garbage collected then it will no free the Qt5 object.

It seems to me that this should be a common problem for any bindings
that include callbacks from C to ocaml. Is everyone using an extra
indirection through a Weak array? Or manual memory management?

Shouldn't there be a way to register a value with the GC as weak?

MfG
	Goswin

                 reply	other threads:[~2016-03-07 20:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20160307203138.GA15388@frosties \
    --to=goswin-v-b@web.de \
    --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;
as well as URLs for NNTP newsgroup(s).