[gst-devel] memory management choices

Murray Cumming murrayc at t-online.de
Sat Nov 9 17:34:02 CET 2002


On Sun, 2002-11-10 at 00:25, Wim Taymans wrote:
> > I'm thinking about how to manage the lifetime of GstObjects in the C++
> 
> > bindings. It's an issue because use of refcounting by default will
> > probably make the C++ API look very different - like gdkmm.
> >
> > GstObjects seem to require refcounting by default, but there is also a
> 
> > gst_object_destroy() function, making them similar to GtkObjects.
> 
> The idea is to make the refcounting similar to GtkObject.
> That said, we've had a few rounds of getting the refcounting right,
> already,
> but it's all still blurry inside my head, mostly because of a lack of
> knowledge
> about GtkObject/Gobject refcounting and confusion about the changes
> between gtk1.2 and 2.0 refcounting. Maybe it's time to go over this
> again...
> 
> >
> > I know that GtkObjects (such as widgets) respond gracefully to
> > gtk_object_destroy() (for instance, child widgets disappear visually
> > from their containers). Is that also true of GstObjects, or is
> > gst_object_destroy() something that should only be used in exceptional
> 
> > circumstances?
> 
> AFAIK, _destroy forcefully destroys the object, like _unref on an object
> with
> a refcount of 1.

That's not a sensible comparison for users of the API, because they
don't know when the refcount is 1.

>  This should also work on GstObjects.
> 
> Are you asking this because you are experiencing problems?

No, we haven't built an API yet so we can't test it. We can't begin to
build that API until we know what memory management choices are
available to us. I'd really like some answer to this questions:

> I know that GtkObjects (such as widgets) respond gracefully to
> > gtk_object_destroy() (for instance, child widgets disappear visually
> > from their containers). Is that also true of GstObjects, or is
> > gst_object_destroy() something that should only be used in exceptional
> > circumstances?

I guess that, if you don't know the answer to this question, then users
of GstObjects don't respond gracefully to the destruction of those
objects. That's fine - we could just ignore gst_object_destroy() and
demand that all objects be refcounted.

However, gst_object_destroy() is used in at least one of the gstreamer
examples - "mixer", so I suspect that there is more to the story. Maybe
you could say when somebody might need to use gst_object_destroy().

I know that you'd prefer to just respond to bug reports, but this is a
fundamental question about the gstreamer API that hopefully has an
answer. Consider it a documentation bug if you like.

-- 
Murray Cumming
murray at usa.net
www.murrayc.com





More information about the gstreamer-devel mailing list