High Memory and Application Stuck

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

High Memory and Application Stuck

adeel
Hi Everyone

I am facing two issues after deploying my app

1. My app is taking too much cpu around 81% and memory around 1.5 GB
2. My app halts after sometime when put in continuous playback or in a loop

My OS is ElCap and decklink driver is 10.5 and gstreamer i am using is 1.8

The scenario is when I put a file in loop it starts from 70 Mb and then it runs for almost 2 days. The program memory rises up to 1.5 GB

My code is as follow


GstBus *bus;
    GSource *timeout_source;
    GSource *bus_source;
    GError *error = NULL;
    //GstElement *audio_sink;
    GstElement *decklink_video_sink;
    //GstElement *deinterlace, *interlace;
    //GstElement *tee, *queue, *video_sink, *queue1;
    GstElement *video_bin, *audio_bin;
    GstElement *video_filter_bin;
   
    GST_DEBUG("Creating pipeline");
    context = g_main_context_new();
    g_main_context_push_thread_default(context);
   
    video_bin = gst_parse_bin_from_description("tee name=t t. ! queue ! autovideosink t. ! decklinkvideosink mode=3", TRUE, NULL);
    video_filter_bin = gst_parse_bin_from_description("capssetter caps=video/x-raw,interlace-mode=interleaved", TRUE, NULL);
    audio_bin = gst_parse_bin_from_description("audioconvert ! autoaudiosink", TRUE, NULL);
   
    pipeline = gst_parse_launch("playbin", &error);
    const char *char_uri = [uri UTF8String];
    g_object_set(pipeline, "uri", char_uri, NULL);
    GST_DEBUG("URI set to %s", char_uri);
   
    g_object_set(pipeline, "video-sink", video_bin, NULL);
    g_object_set(pipeline, "video-filter", video_filter_bin, NULL);
    g_object_set(pipeline, "audio-sink", audio_bin, NULL);
   
   if(error){
    gchar *message = g_strdup_printf("Unable to build pipeline: %s", error->message);
    g_clear_error(&error);
    NSLog(@"pipeline error %s",message);
    [self setUIMessage:message];
    g_free(message);
    return;
   }
   
   GstElement *videosink = gst_bin_get_by_interface(GST_BIN(pipeline), GST_TYPE_VIDEO_OVERLAY);
   if(!videosink){
       GST_ERROR("Could not retrieve video sink");
       return;
   }
   
   gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(videosink), (guintptr)(id)ui_video_view);
   
    ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
    if (ret == GST_STATE_CHANGE_FAILURE) {
        NSLog(@"Unable to set the pipeline to the playing state.\n");
        gst_object_unref (pipeline);
        return;
    }
   
    bus = gst_element_get_bus(pipeline);
    bus_source = gst_bus_create_watch(bus);
    g_source_set_callback(bus_source, (GSourceFunc)gst_bus_async_signal_func, NULL, NULL);
    g_source_attach(bus_source, context);
    g_source_unref(bus_source);
    g_signal_connect (G_OBJECT(bus), "message::error", (GCallback)error_cb, (__bridge void *)self);
    g_signal_connect (G_OBJECT(bus), "message::eos", (GCallback)eos_cb, (__bridge void *)self);
    g_signal_connect (G_OBJECT(bus), "message::state-changed", (GCallback)state_changed_cb, (__bridge void *)self);
    g_signal_connect (G_OBJECT(bus), "message::duration", (GCallback)duration_cb, (__bridge void *)self);
    g_signal_connect (G_OBJECT(bus), "message::clock-lost", (GCallback)clock_lost_cb, (__bridge void *)self);
    g_signal_connect (pipeline, "about-to-finish", (GCallback)prepare_next_stream, (__bridge void *)self);
    timeout_source = g_timeout_source_new(1);
    g_source_set_callback(timeout_source, (GSourceFunc)refresh_ui, (__bridge void *)self,NULL);
    g_source_attach(timeout_source, context);
    g_source_unref(timeout_source);
   
   
    GST_DEBUG("Entering main loop...");
    main_loop = g_main_loop_new(context, FALSE);
    [self check_initializing_complete];
    g_main_loop_run(main_loop);
    GST_DEBUG("Exiting main loop...");
    g_main_loop_unref(main_loop);
    main_loop = NULL;
   
    g_main_context_pop_thread_default(context);
    g_main_context_unref(context);
    gst_object_unref (bus);
    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (pipeline);
   
    pipeline = NULL;
    timeout_source = NULL;
    bus = NULL;
    bus_source = NULL;
   

    return;


How can handle memory

Regards
Adeel Arshad
Reply | Threaded
Open this post in threaded view
|

Re: High Memory and Application Stuck

Sebastian Dröge-3
On Mon, 2016-10-10 at 03:36 -0700, adeel wrote:

> Hi Everyone
>
> I am facing two issues after deploying my app 
>
> 1. My app is taking too much cpu around 81% and memory around 1.5 GB
> 2. My app halts after sometime when put in continuous playback or in a loop
>
> My OS is ElCap and decklink driver is 10.5 and gstreamer i am using is 1.8
>
> The scenario is when I put a file in loop it starts from 70 Mb and then it
> runs for almost 2 days. The program memory rises up to 1.5 GB
You will need to do some memory profiling for your application to
isolate the place where the memory usage is increasing. XCode iirc also
has something for that, otherwise something like valgrind's memcheck
might help here or the new leaks tracer in GStreamer 1.9.2+.

Also try to minimalize your pipeline for testing this, so that it's
easier to find the culprit between all the other code.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (985 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: High Memory and Application Stuck

adeel
Hi 

Thanks for your response

Enclosed are the memory leaks status of my application. Can you please help me to get an idea what I am doing wrong

Regards
Adeel Arshad

On Thu, Oct 13, 2016 at 1:13 PM, Sebastian Dröge <[hidden email]> wrote:
On Mon, 2016-10-10 at 03:36 -0700, adeel wrote:
> Hi Everyone
>
> I am facing two issues after deploying my app 
>
> 1. My app is taking too much cpu around 81% and memory around 1.5 GB
> 2. My app halts after sometime when put in continuous playback or in a loop
>
> My OS is ElCap and decklink driver is 10.5 and gstreamer i am using is 1.8
>
> The scenario is when I put a file in loop it starts from 70 Mb and then it
> runs for almost 2 days. The program memory rises up to 1.5 GB

You will need to do some memory profiling for your application to
isolate the place where the memory usage is increasing. XCode iirc also
has something for that, otherwise something like valgrind's memcheck
might help here or the new leaks tracer in GStreamer 1.9.2+.

Also try to minimalize your pipeline for testing this, so that it's
easier to find the culprit between all the other code.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com

_______________________________________________
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

Screen Shot 2016-10-18 at 12.15.39 PM.png (319K) Download Attachment
Screen Shot 2016-10-18 at 1.17.41 PM.png (459K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: High Memory and Application Stuck

Mikl

Hello, Adeel


First i will look is are you cleaning up all the buffers after usage.

gst_buffer_unref(buffer);


Can you show source code, please?


Mikl

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

Re: High Memory and Application Stuck

Sebastian Dröge-3
In reply to this post by adeel
On Tue, 2016-10-18 at 13:20 +0500, Adeel Arshad wrote:
> Hi 
>
> Thanks for your response
>
> Enclosed are the memory leaks status of my application. Can you
> please help me to get an idea what I am doing wrong

What's your pipeline, what elements are used in there, do you have any
pad probes, appsink or similar to get buffers from the pipeline to the
application?

Basically this looks like a lot of raw video buffers are leaked
somewhere. The ones allocated by the decoder.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (949 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: High Memory and Application Stuck

adeel
In reply to this post by Mikl
This is my source code for play file

GstBus *bus;
    GSource *timeout_source;
    GSource *bus_source;
    GError *error = NULL;
    //GstElement *audio_sink;
    GstElement *decklink_video_sink;
    //GstElement *deinterlace, *interlace;
    //GstElement *tee, *queue, *video_sink, *queue1;
    GstElement *video_bin, *audio_bin;
    GstElement *video_filter_bin;

    GST_DEBUG("Creating pipeline");
    context = g_main_context_new();
    g_main_context_push_thread_default(context);

    video_bin = gst_parse_bin_from_description("tee name=t t. ! queue !
autovideosink t. ! decklinkvideosink mode=3", TRUE, NULL);
    video_filter_bin = gst_parse_bin_from_description("capssetter
caps=video/x-raw,interlace-mode=interleaved", TRUE, NULL);
    audio_bin = gst_parse_bin_from_description("audioconvert !
autoaudiosink", TRUE, NULL);

    pipeline = gst_parse_launch("playbin", &error);
    const char *char_uri = [uri UTF8String];
    g_object_set(pipeline, "uri", char_uri, NULL);
    GST_DEBUG("URI set to %s", char_uri);

    g_object_set(pipeline, "video-sink", video_bin, NULL);
    g_object_set(pipeline, "video-filter", video_filter_bin, NULL);
    g_object_set(pipeline, "audio-sink", audio_bin, NULL);

   if(error){
    gchar *message = g_strdup_printf("Unable to build pipeline: %s",
error->message);
    g_clear_error(&error);
    NSLog(@"pipeline error %s",message);
    [self setUIMessage:message];
    g_free(message);
    return;
   }

   GstElement *videosink = gst_bin_get_by_interface(GST_BIN(pipeline),
GST_TYPE_VIDEO_OVERLAY);
   if(!videosink){
       GST_ERROR("Could not retrieve video sink");
       return;
   }

   gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(videosink),
(guintptr)(id)ui_video_view);

    ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
    if (ret == GST_STATE_CHANGE_FAILURE) {
        NSLog(@"Unable to set the pipeline to the playing state.\n");
        gst_object_unref (pipeline);
        return;
    }

    bus = gst_element_get_bus(pipeline);
    bus_source = gst_bus_create_watch(bus);
    g_source_set_callback(bus_source,
(GSourceFunc)gst_bus_async_signal_func, NULL, NULL);
    g_source_attach(bus_source, context);
    g_source_unref(bus_source);
    g_signal_connect (G_OBJECT(bus), "message::error", (GCallback)error_cb,
(__bridge void *)self);
    g_signal_connect (G_OBJECT(bus), "message::eos", (GCallback)eos_cb,
(__bridge void *)self);
    g_signal_connect (G_OBJECT(bus), "message::state-changed",
(GCallback)state_changed_cb, (__bridge void *)self);
    g_signal_connect (G_OBJECT(bus), "message::duration",
(GCallback)duration_cb, (__bridge void *)self);
    g_signal_connect (G_OBJECT(bus), "message::clock-lost",
(GCallback)clock_lost_cb, (__bridge void *)self);
    g_signal_connect (pipeline, "about-to-finish",
(GCallback)prepare_next_stream, (__bridge void *)self);
    timeout_source = g_timeout_source_new(1);
    g_source_set_callback(timeout_source, (GSourceFunc)refresh_ui, (__bridge
void *)self,NULL);
    g_source_attach(timeout_source, context);
    g_source_unref(timeout_source);


    GST_DEBUG("Entering main loop...");
    main_loop = g_main_loop_new(context, FALSE);
    [self check_initializing_complete];
    g_main_loop_run(main_loop);
    GST_DEBUG("Exiting main loop...");
    g_main_loop_unref(main_loop);
    main_loop = NULL;

    g_main_context_pop_thread_default(context);
    g_main_context_unref(context);
    gst_object_unref (bus);
    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (pipeline);

    pipeline = NULL;
    timeout_source = NULL;
    bus = NULL;
    bus_source = NULL;


    return;

On Tue, Oct 18, 2016 at 3:08 PM, Michael Yarochkin <[hidden email]> wrote:

Hello, Adeel


First i will look is are you cleaning up all the buffers after usage.

gst_buffer_unref(buffer);


Can you show source code, please?


Mikl

_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: High Memory and Application Stuck

adeel
In reply to this post by Sebastian Dröge-3
Hi Sebastian

This is my pipeline

    video_bin = gst_parse_bin_from_description("tee name=t t. ! queue !
autovideosink t. ! decklinkvideosink mode=3", TRUE, NULL);
    video_filter_bin = gst_parse_bin_from_description("capssetter
caps=video/x-raw,interlace-mode=interleaved", TRUE, NULL);
    audio_bin = gst_parse_bin_from_description("audioconvert !
autoaudiosink", TRUE, NULL);

    pipeline = gst_parse_launch("playbin", &error);
    const char *char_uri = [uri UTF8String];
    g_object_set(pipeline, "uri", char_uri, NULL);
    GST_DEBUG("URI set to %s", char_uri);

    g_object_set(pipeline, "video-sink", video_bin, NULL);
    g_object_set(pipeline, "video-filter", video_filter_bin, NULL);
    g_object_set(pipeline, "audio-sink", audio_bin, NULL);

I don't have any pad probes, appsink or similar to get buffers from the pipeline to the application



On Tue, Oct 18, 2016 at 3:11 PM, Sebastian Dröge <[hidden email]> wrote:
On Tue, 2016-10-18 at 13:20 +0500, Adeel Arshad wrote:
> Hi 
>
> Thanks for your response
>
> Enclosed are the memory leaks status of my application. Can you
> please help me to get an idea what I am doing wrong

What's your pipeline, what elements are used in there, do you have any
pad probes, appsink or similar to get buffers from the pipeline to the
application?

Basically this looks like a lot of raw video buffers are leaked
somewhere. The ones allocated by the decoder.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com

_______________________________________________
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