gstreamer-sharp RAW video appsink memory leak

Camera.Geomatics at leica-geosystems.com Camera.Geomatics at leica-geosystems.com
Tue May 31 09:19:20 UTC 2016


Hello

This problem described seems to be related to bug 677708:
https://bugzilla.gnome.org/show_bug.cgi?id=677708

Workaround is shown in bug description.

blad


From:   Camera Geomatics/CHHER/Central/Leica
To:     gstreamer-devel at lists.freedesktop.org
Date:   26.05.2016 22:35
Subject:        gstreamer-sharp RAW video appsink memory leak
Sent by:        Daniel Blaser



Hello

We are trying to pull RAW video frames from appsink, using gstreamer 
sharp.

It looks like the samples are not freed even when calling Dispose() on the 
sample, resulting i a huge memoryleak (~30MB a second....)

Tested with gstreamer 1.8.1 and gstreamer-sharp#HEAD on Ubuntu 14.04 and 
gstreamer 1.4.5 and gstreamer-sharp on Windows.

Any ideas what is wrong at our sample code?

----------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Gst;
using System.Runtime.InteropServices;

namespace AppSinkSample
{
    class Program
    {
        static Element VideoTestSource, VideoCaps, VideoSink, AppQueue;
        static Gst.App.AppSink AppSink;

        static GLib.MainLoop MainLoop; // GLib's Main Loop

        // The appsink has received a buffer
        static void NewSample(object sender, GLib.SignalArgs args)
        {
            var sink = (Gst.App.AppSink)sender;

            // Retrieve the buffer
            var sample = sink.PullSample();
            if (sample != null)
            {
                // The only thing we do in this example is print a * to 
indicate a received buffer
                Console.Write("*");
                sample.Dispose();
            }
        }

        static void Main(string[] args)
        {
            // Initialize Gstreamer
            Gst.Application.Init(ref args);

            // Create the elements
            VideoTestSource = ElementFactory.Make("videotestsrc", 
"videotestsrc0");
            VideoCaps = ElementFactory.Make("capsfilter", "capsfilter0");
            AppQueue = ElementFactory.Make("queue", "app_queue");
            AppSink = new Gst.App.AppSink("app_sink");
 
            // Create the empty pipeline
            var pipeline = new Pipeline("test-pipeline");

            if (VideoTestSource == null || VideoCaps == null || AppQueue 
== null || AppSink == null)
            {
                return;
            }

            // Configure videotestsrc
            VideoTestSource["pattern"] = "snow";
            VideoCaps["caps"] = 
Gst.Caps.FromString("video/x-raw,width=640,height=480");

            // Configure appsink
            AppSink["emit-signals"] = true;
            AppSink.NewSample += NewSample;

            pipeline.Add(VideoTestSource, VideoCaps, AppQueue, AppSink);

            if (!Element.Link(VideoTestSource, VideoCaps) || 
!Element.Link(VideoCaps, AppQueue) || !Element.Link(AppQueue, AppSink))
            {
                return;
            }

            // Start playing the pipeline
            pipeline.SetState(State.Playing);

            // Create a GLib Main Loop and set it to run
            MainLoop = new GLib.MainLoop();
            MainLoop.Run();

            // Free resources
            pipeline.SetState(State.Playing);

        }
    }
}


----------------------------

Regards
blad



More information about the gstreamer-devel mailing list