Properly freeing resources
Jim
restlessmindsstudio at gmail.com
Wed Feb 27 09:42:14 PST 2013
I found out from the producer of the hardware I'm using that what I was
experiencing here is disk caching. As the video is playing, it is being
loaded into memory. Linux would have discarded pages if other processes
needed memory. I was given the following command to manually flush the disk
cache:
for n in 1 2 3 ; do
echo $n > /proc/sys/vm/drop_caches ;
done
After executing this I could see it freed all this memory.
Jim
-----Original Message-----
As I continue to try and figure out what is causing this apparent memory
leak in my application, I decided to perform a sanity check by monitoring
system memory while just running gst-launch.
I'm finding that even gst-launch is resulting in a memory drain. I'm
watching the used and free memory available to the system and in 15 minutes,
used memory went from 22MB (before launching gst-launch) to 238MB and it
continues to grow at a fairly steady rate. If I look at the allocated memory
for gst-launch, it's at 88MB. Where is all this free memory going?
Is this normal behavior for GStreamer?
By the way, the command line I'm using is: gst-launch playbin2
uri=file:///video.ts
Thanks,
Jim
-----Original Message-----
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 Tim-Philipp Müller
Sent: Friday, February 22, 2013 12:41 PM
To: gstreamer-devel at lists.freedesktop.org
Subject: Re: Properly freeing resources
On Wed, 2013-02-20 at 07:41 -0700, Jim wrote:
Hi,
your code looks mostly ok.
> 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");
I would check these elements first, if they free all resources correctly
when being shut down and/or being shut down during playback.
> g_object_set(G_OBJECT(streamData->videoQueue), "max-size-time", 0,
NULL);
> g_object_set(G_OBJECT(streamData->audioQueue), "max-size-time", 0,
> NULL);
You want (guint64)0 here.
> g_signal_connect(streamData->demux, "pad-added",
> G_CALLBACK(pad_added_handler), streamData);
What do you do in the pad_added_handler? Are you sure you are not leaking
any references there?
> // 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);
FWIW, you don't have to keep a ref to the bus around if you don't need it,
you can just unref it right here and there after adding the watch if you
want to.
> 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);
You will also need to
to g_source_remove (streamData->busWatchId)
Cheers
-Tim
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
More information about the gstreamer-devel
mailing list