Properly freeing resources

Jim restlessmindsstudio at gmail.com
Wed Feb 20 13:50:15 PST 2013


No, unfortunately it looks like the memory usage is still slowly increasing.

 

Since no one else is speaking up I'll have to assume that means I must be
freeing resources correctly. I think I'll contact Freescale since I'm using
their plugins with GStreamer.

 

Thanks,

Jim

 

From:
gstreamer-devel-bounces+restlessmindsstudio=gmail.com at lists.freedesktop.org
[mailto:gstreamer-devel-bounces+restlessmindsstudio=gmail.com at lists.freedesk
top.org] On Behalf Of Bernhard Graaf
Sent: Wednesday, February 20, 2013 1:37 PM
To: 'Discussion of the development of and with GStreamer'
Subject: AW: Properly freeing resources

 

Does it helps?

 

 

Von: gstreamer-devel-bounces+bernhard.graaf=gmx.de at lists.freedesktop.org
[mailto:gstreamer-devel-bounces+bernhard.graaf=gmx.de at lists.freedesktop.org]
Im Auftrag von Jim
Gesendet: Mittwoch, 20. Februar 2013 15:41
An: 'Discussion of the development of and with GStreamer'
Betreff: RE: Properly freeing resources

 

Thanks I'll give that a try!

 

Jim

 

From:
gstreamer-devel-bounces+restlessmindsstudio=gmail.com at lists.freedesktop.org
[mailto:gstreamer-devel-bounces+restlessmindsstudio=gmail.com at lists.freedesk
top.org] On Behalf Of Bernhard Graaf
Sent: Tuesday, February 19, 2013 11:38 PM
To: 'Discussion of the development of and with GStreamer'
Subject: AW: Properly freeing resources

 

I've found a small mismatch:

The 'gst_object_unref(streamData->bus)' should be called after init the
signal bus, not before sending a new video.

 

Hope that helps

Bernhard

 

Von: gstreamer-devel-bounces+bernhard.graaf=gmx.de at lists.freedesktop.org
[mailto:gstreamer-devel-bounces+bernhard.graaf=gmx.de at lists.freedesktop.org]
Im Auftrag von Jim
Gesendet: Dienstag, 19. Februar 2013 19:03
An: gstreamer-devel at lists.freedesktop.org
Betreff: Properly freeing resources

 

Hi Everyone,

I've been watching the memory usage of my C application that's using
Gstreamer 0.10.36 and notice the allocated memory (according to the top
command) keeps increasing slowly over time. This is only happening while
Gstreamer is playing a video. When the application is idle, not using
Gstreamer, the memory usage does not increase. I'm wondering if I'm doing
something wrong with how I'm using the Gstreamer library.

 

The application is basically a media player that provides the user with a
list of videos to play. At any time the user can switch to a different
video. Every time it starts playing another video, it goes through the
following initialization:

 

  // Create the pipeline and its elements

  streamData->pipeline = gst_pipeline_new("my-pipeline");

  streamData->fileSrc = gst_element_factory_make("filesrc", "fileSrc");

  streamData->demux = gst_element_factory_make("tsdemux", "demux");

  streamData->videoQueue = gst_element_factory_make("queue", "videoQueue");

  streamData->audioQueue = gst_element_factory_make("queue", "audioQueue");

  streamData->videoDecoder = gst_element_factory_make("vpudec",
"videoDecoder");

  streamData->videoSink = gst_element_factory_make("mfw_v4lsink",
"videoSink");

  streamData->audioDecoder = gst_element_factory_make("mfw_mp3decoder",
"audioDecoder");

  streamData->volumeFilter = gst_element_factory_make("volume", "volume");

  streamData->audioSink = gst_element_factory_make("alsasink", "audioSink");

 

  if (!streamData->pipeline || !streamData->fileSrc || !streamData->demux ||
!streamData->videoQueue ||

      !streamData->audioQueue || !streamData->videoDecoder ||
!streamData->videoSink ||

      !streamData->audioDecoder || !streamData->volumeFilter ||
!streamData->audioSink)

  {

    g_printerr("Not all elements could be created.\n");

    return;

  }

 

  gst_bin_add_many(GST_BIN(streamData->pipeline), streamData->fileSrc,
streamData->demux, streamData->videoQueue,

                   streamData->audioQueue, streamData->videoDecoder,
streamData->videoSink, streamData->audioDecoder,

                   streamData->volumeFilter, streamData->audioSink, NULL);

  if (!gst_element_link(streamData->fileSrc, streamData->demux))

  {

    g_printerr("Elements could not be linked\n");

    gst_object_unref(streamData->pipeline);

    return;

  }

 

  if (!gst_element_link_many(streamData->videoQueue,
streamData->videoDecoder, streamData->videoSink, NULL))

  {

    g_printerr("Elements could not be linked\n");

    gst_object_unref(streamData->pipeline);

    return;

  }

 

  if (!gst_element_link_many(streamData->audioQueue,
streamData->audioDecoder, streamData->volumeFilter, streamData->audioSink,
NULL))

  {

    g_printerr("Elements could not be linked\n");

    gst_object_unref(streamData->pipeline);

    return;

  }

 

  g_object_set(G_OBJECT(streamData->videoQueue), "max-size-buffers", 0,
NULL);

  g_object_set(G_OBJECT(streamData->videoQueue), "max-size-time", 0, NULL);

  g_object_set(G_OBJECT(streamData->audioQueue), "max-size-buffers", 0,
NULL);

  g_object_set(G_OBJECT(streamData->audioQueue), "max-size-time", 0, NULL);

 

  g_signal_connect(streamData->demux, "pad-added",
G_CALLBACK(pad_added_handler), streamData);

 

  // Retrieve pipeline signal bus

  streamData->bus =
gst_pipeline_get_bus(GST_PIPELINE(streamData->pipeline));

  streamData->busWatchId = gst_bus_add_watch(streamData->bus,
(GstBusFunc)handle_message, streamData);

 

 

Before switching to a another video, the following cleanup is done:

 

  gst_object_unref(streamData->bus);

  gst_element_set_state(streamData->pipeline, GST_STATE_NULL);

  gst_object_unref(streamData->pipeline);

 

Is this all the cleanup I need to do before creating a new pipeline or is
there something else?

 

Thanks,

Jim

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20130220/abef1b9e/attachment-0001.html>


More information about the gstreamer-devel mailing list