How to properly release the memory used by a pipeline?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to properly release the memory used by a pipeline?

vasconce1o

I am developing a program that need to create and delete a pipeline several times, but memory grows every time I do this.

So I developed this simple example for find out what is wrong, but memory leaks still appers.

I also do GST_DEBUG=GST_REFCOUNTING:5, but nothing.

How should I properly release the memory used by a pipeline?

I am using GStreamer 1.12.2 and Ubuntu 14.04.

For example this code:

int main(int argc, char* argv[]) {
    g_print("gst_init...\n");
    gst_init(NULL, NULL);
    sleep(10);

    for (int pp = 0; pp < 10; pp++) {
        g_print("Iter #%d \n",pp);
        GstElement *pipeline;
        GError* err = NULL;

        pipeline = gst_parse_launch(
            " filesrc location=/media/datos/video12.mp4 "
            " ! qtdemux ! avdec_h264 ! videoconvert ! fakesink name=appsink",
            &err);

        if (err) {
            g_printerr(err->message);
            g_error_free(err);
            return -1;
        }
        gst_element_set_state(pipeline, GST_STATE_PLAYING);

        sleep(5);

        gst_element_set_state(pipeline, GST_STATE_NULL);
        gst_object_unref(GST_OBJECT(pipeline));
        sleep(5);
    }

    gst_deinit();
    g_print("gst_deinit...\n");
    sleep(10);

    return 0;
}

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to properly release the memory used by a pipeline?

Tim Müller
On Fri, 2017-09-22 at 20:22 -0400, Yuniesky Vasconcelo wrote:

Hi,

Your code looks fine at first glance. Setting pipeline to NULL state
and unrefing it should be all that's needed. You don't use the bus, so
you're not leaking bus messages either.

How do you measure "memory grows every time"?

You can use

  G_SLICE=always-malloc valgrind --leak-check=yes --show-reachable=no
gst-launch-1.0 ...

(might want to use some .supp suppression files which you can find in
the gstreamer git repos).

Cheers
 -Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.com

Join us at the GStreamer Conference!
21-22 October 2017 in Prague, Czech Republic
http://gstreamer.freedesktop.org/conference/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to properly release the memory used by a pipeline?

vasconce1o
Thank you Tim.
I measure memory growth with htop, so I use the sleep function to give me time to see what happened to memory.


2017-09-23 4:17 GMT-04:00 Tim Müller <[hidden email]>:
On Fri, 2017-09-22 at 20:22 -0400, Yuniesky Vasconcelo wrote:

Hi,

Your code looks fine at first glance. Setting pipeline to NULL state
and unrefing it should be all that's needed. You don't use the bus, so
you're not leaking bus messages either.

How do you measure "memory grows every time"?

You can use

  G_SLICE=always-malloc valgrind --leak-check=yes --show-reachable=no
gst-launch-1.0 ...

(might want to use some .supp suppression files which you can find in
the gstreamer git repos).

Cheers
 -Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.com

Join us at the GStreamer Conference!
21-22 October 2017 in Prague, Czech Republic
http://gstreamer.freedesktop.org/conference/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel