caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] wrapper for C++ class never gets garbage collected
@ 2016-03-07 20:31 Goswin von Brederlow
  0 siblings, 0 replies; only message in thread
From: Goswin von Brederlow @ 2016-03-07 20:31 UTC (permalink / raw)
  To: Ocaml Mailing List

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-03-07 20:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-07 20:31 [Caml-list] wrapper for C++ class never gets garbage collected Goswin von Brederlow

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).