[Bug 667949] New: Memory leak occurs while using videomixer2 element

GStreamer (bugzilla.gnome.org) bugzilla at gnome.org
Sun Jan 15 02:14:12 PST 2012

  GStreamer | gst-plugins-good | 0.10.36

           Summary: Memory leak occurs while using videomixer2 element
    Classification: Platform
           Product: GStreamer
           Version: 0.10.36
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: Normal
         Component: gst-plugins-good
        AssignedTo: gstreamer-bugs at lists.freedesktop.org
        ReportedBy: juhsis at yahoo.com
         QAContact: gstreamer-bugs at lists.freedesktop.org
     GNOME version: ---

Dear Developers,

Here is my code for generate 2 IplImages (in OpenCv) with using gstreamer
elements. I've created this system: 

v4l2src -> videobox -> 
                    -> videomixer2 -> videoflip -> ffmpegcolorspace -> appsink 
v4l2src -> videobox -> 

But memory leakage detected. I changed videomixer2 with videomixer element,
leakage problem fixed but fps of images decreased from 30 to 2-3. And i also
tried to make 2 seperate systems:

v4l2src -> videobox -> videoflip -> ffmpegcolorspace -> appsink 

there was also no memory leak in this systems, but they are not syncronised and
getting close in 10 seconds, when both of them works.

So, i definitely decide videmixer2 element has some problems. Actually memory
leak is not happens everytime. If the image consists a lot of same pixels, then
memory leak detected, but if the image consists complex intend: no leak

Here is my own code, you can try it : 

#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv/cxcore.h>
#include <opencv/cvaux.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
#include <gst/gst.h>
#include <gst/app/gstappsrc.h>
#include <gst/app/gstappsink.h>
#include <gst/app/gstappbuffer.h>
#define SCAL1 2 
#define SHOWIN 1 

unsigned char *ptr; 
IplImage* frameL; 
IplImage* frameR; 
GstElement *pipeline; 
static void on_new_buffer_from_source (GstElement * elt, void * data) 
        guint size; 
        GstBuffer *buffer; 
        int sizeovertwo; 

        buffer = gst_app_sink_pull_buffer (GST_APP_SINK (elt)); 
        size = GST_BUFFER_SIZE (buffer); 
        sizeovertwo = size/2; 
        ptr = (unsigned char *)GST_BUFFER_DATA (buffer); 

        for(unsigned int r = 0; r < sizeovertwo; r++) 
        for(unsigned int r = 0; r < sizeovertwo; r++) 
        ptr = NULL; 
        int cmd = cvvWaitKeyEx( 0, 1 ); 
        system("free -mb"); 
        cvvShowImage( "source left", frameL ); 
        cvvShowImage( "source right", frameR ); 


int main( int argc, char** argv ) 
        GstElement *ffmpegcolor = NULL; 
        gst_init (&argc, &argv); 
        GstElement *source,*source2,*mix; 
        GstElement *vb,*vb2; 
        GstElement *sink; 
        GstElement *vf; 
        GstPad *sink_0,*sink_1; 
        GstPad *src_0,*src_1; 
        GstCaps *caps,*caps2; 
        gboolean link_ok=true; 
        gboolean link_ok2=true; 
        gboolean link_ok3=true; 

        caps = gst_caps_new_full ( 
                gst_structure_new ("video/x-raw-yuv", 
                         "width", G_TYPE_INT, 640/SCAL1, 
                         "height", G_TYPE_INT, 480/SCAL1, 
                         "framerate", GST_TYPE_FRACTION, 20, 1, 
        caps2 = gst_caps_new_full ( 
                gst_structure_new ("video/x-raw-gray", 
                         "width", G_TYPE_INT, 480/SCAL1, 
                         "height", G_TYPE_INT, 1280/SCAL1, 
                         "framerate", GST_TYPE_FRACTION, 20, 1, 
        pipeline = gst_pipeline_new ("my-pipeline"); 
        source = gst_element_factory_make("v4l2src", "source"); 
        source2 = gst_element_factory_make("v4l2src", "source2"); 
     g_object_set(G_OBJECT(source), "device", "/dev/video0", NULL); 
     g_object_set(G_OBJECT(source2), "device", "/dev/video1", NULL); 
        mix = gst_element_factory_make("videomixer2", "mix"); 
        vb = gst_element_factory_make("videobox", "vb"); 
        vb2 = gst_element_factory_make("videobox", "vb2"); 
        vf = gst_element_factory_make("videoflip", "vf"); 
     g_object_set(G_OBJECT(vb2), "left",(gint)-640/SCAL1, NULL); 
     g_object_set(G_OBJECT(vf), "method",1, NULL); 
        ffmpegcolor = gst_element_factory_make ("ffmpegcolorspace", NULL); 
        sink = gst_element_factory_make("appsink", "sink"); 
        gst_app_sink_set_drop((GstAppSink *)sink,true); 
     g_object_set(G_OBJECT(sink), "max-buffers",(guint)1, NULL); 
(pipeline),source,source2,vb,vb2,mix,ffmpegcolor,vf,sink, NULL); 

        link_ok = gst_element_link_filtered (source, vb, caps); 
        link_ok2 = gst_element_link_filtered (source2, vb2, caps); 

        sink_0 = gst_element_get_request_pad (mix, "sink_0"); 
        sink_1 = gst_element_get_request_pad (mix, "sink_1"); 
        src_0 = gst_element_get_static_pad (vb, "src"); 
        src_1 = gst_element_get_static_pad (vb2, "src"); 
  gst_pad_link (src_0,sink_1); 
  gst_pad_link (src_1,sink_0); 

        gst_element_link_many(mix, vf, ffmpegcolor, NULL); 
        link_ok3 = gst_element_link_filtered (ffmpegcolor,sink, caps2); 

        gst_caps_unref (caps); 
        gst_caps_unref (caps2); 

        if (!link_ok) { 
                g_warning ("Failed to link element1 and element2 --1--!"); 
        if (!link_ok2) { 
                g_warning ("Failed to link element1 and element2 --2--!"); 
        if (!link_ok3) { 
                g_warning ("Failed to link element1 and element2 --2--!"); 
        g_object_set (G_OBJECT (sink), "emit-signals", TRUE, "sync", FALSE,
        g_signal_connect (sink, "new-buffer", G_CALLBACK
(on_new_buffer_from_source), NULL); 
        frameR = cvCreateImage(cvSize(480/SCAL1, 640/SCAL1), IPL_DEPTH_8U, 1); 
        frameL = cvCreateImage(cvSize(480/SCAL1, 640/SCAL1), IPL_DEPTH_8U, 1); 
        gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING); 
        g_print ("Let's run!\n"); 

        cvNamedWindow("source left", 1); 
        cvNamedWindow("source right", 1); 


    return 0; 

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