[gstreamer-bugs] [Bug 636804] Using appsink causes memory leak because buffers are double ref'ed by gst-sharp

GStreamer (bugzilla.gnome.org) bugzilla at gnome.org
Sun Dec 12 08:51:54 PST 2010


https://bugzilla.gnome.org/show_bug.cgi?id=636804
  GStreamer | gst-sharp | 0.10.x

--- Comment #2 from William Lahti <wilahti at gmail.com> 2010-12-12 16:51:50 UTC ---
Created an attachment (id=176299)
 --> (https://bugzilla.gnome.org/attachment.cgi?id=176299)
test case demonstrating AppSink.PullBuffer memory leak

Doesnt gst_appsink_pull_buffer return a referenced buffer, which then need only
be unreferenced when the app is finished using it?

I have been looking into the relevant code, and it appears that the generated
PullBuffer implementation treats buffers returned by gst_appsink_pull_buffer as
unowned when passed to Gst.MiniBuffer.GetObject (it uses the single parameter
overload which defaults the second parameter "owned_ref" to false), but I
believe they are actually already referenced by gst-app, and need only be
unreferenced when the proxy object is disposed. Instead, since they are treated
as "unowned" when they are wrapped, Gst.Buffer.GetObject then references them
before return. 

The testcase is based on the appsrc sample, and has a switch comment for
swapping out appsink for fakesink to see the difference in memory usage. The
observed behavior for me with gstreamer-sharp 0.9.2 is a steady memory leak
(slow for default videotestsrc buffers, but visible).

It can be compiled with:

gmcs AppSink.cs /r:gstreamer-sharp -pkg:glib-sharp-2.0

Additionally, I have left the gst_minibuffer_unref pinvoke in there, with the
call commented out, so you can see how unrefing before dispose fixes the
problem.

I believe I have fixed this in my working copy, but just for PullBuffer.
Presumably this same problem applies to the generated implementations of
PullBufferList et al. If someone can confirm that appsink does in fact leave a
ref for the application on buffers then I can go ahead and finish fixing the
other PullBuffer variants and post a patch. 

Also, I am fixing by adding the hidden attribute to the gst_appsink_pull_buffer
method in GStreamer.metadata file, then adding a custom implementation in
AppSink.custom. Is this the correct way to fix this? Alternatively, the
GetObject() method in the MiniObject class could be set to default the
owned_ref parameter to true, but I don't know if this is appropriate for all
it's uses.

-- 
Configure bugmail: https://bugzilla.gnome.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.




More information about the Gstreamer-bugs mailing list