I am creating Gstreamer pipelines oni.MX6 platform using Gstreamer API. There are two example pipelines, one just connects video source to a video sink, another adds deinterlacer:
int deinterlace(void)
{
gst_element_set_state(stopPipe.pipeline, GST_STATE_NULL);
gst_object_unref(stopPipe.pipeline);
stopPipe.pipeline = NULL;
recPipe.pipeline = gst_pipeline_new("gst_RecPipeline");
recPipe.videoSrc = gst_element_factory_make(GST_SRC, "recPipe.videoSrc");
recPipe.vidTrans1 = gst_element_factory_make(GST_VID_TRANS, "recPipe.vidTrans1");
recPipe.dispSink = gst_element_factory_make(GST_SINK, "recPipe.dispSink");
g_object_set(recPipe.vidTrans1, "deinterlace", 3, NULL); // enable deinterlacing
gst_bin_add_many(GST_BIN(recPipe.pipeline), recPipe.videoSrc, recPipe.vidTrans1, recPipe.dispSink, NULL);
gst_element_link_many(recPipe.videoSrc, recPipe.vidTrans1, recPipe.dispSink, NULL);
gst_element_set_state(recPipe.pipeline, GST_STATE_PLAYING);
}
int raw(void)
{
gst_element_set_state(recPipe.pipeline, GST_STATE_NULL);
gst_object_unref(recPipe.pipeline);
recPipe.pipeline = NULL;
stopPipe.pipeline = gst_pipeline_new("stopPipe");
stopPipe.videoSrc = gst_element_factory_make(GST_SRC, "stopPipe.videoSrc");
stopPipe.dispSink = gst_element_factory_make(GST_SINK, "stopPipe.dispSink");
gst_bin_add_many(GST_BIN(stopPipe.pipeline), stopPipe.videoSrc, stopPipe.dispSink, NULL);
gst_element_link_many(stopPipe.videoSrc, stopPipe.dispSink, NULL);
gst_element_set_state(stopPipe.pipeline, GST_STATE_PLAYING);
}
The main loop calls each of the functions (manually or just after timeout). Every time a pipeline is created, more memory is allocated, but it does not seem to be ever released, as every pair of created/destroyed pipelines increases application memory consumption by ~8MB. Eventually the application just runs out of memory. The issue does not seem to be specific to Gstreamer pipelines. If I create a Qt application creating and destroying different layouts, the behaviour will be similar, that is every pair of created/destroyed layouts will add ~8MB to the application. When the application terminates, all memory goes back to normal.
I have traced that in Linux 3.10.17, and in Linux 3.14.28, using both gstreamer-0.10, and gstreamer-1.0.
My question is: what can in i.MX6 (framebuffer?) cause this behaviour and, more importantly, how to deal with it?