C++ gstreamer管道设置为GST\u STATE\u NULL后未释放内存
我的应用程序需要多次重新启动gstreamer管道。 但是在将管道设置为GST_STATE_NULL并在管道上调用unref之后,内存似乎没有被释放。 每次重新启动后,与进程相关的内存不断增加 我仅使用videotestsrc fakesink元素就可以重现问题,如下所示: //g++-Wall testpage_Simple.cpp-o testpage_Simple$(pkg config--cflags--libs gstreamer-1.0)C++ gstreamer管道设置为GST\u STATE\u NULL后未释放内存,c++,c,video,gstreamer,gstreamer-1.0,C++,C,Video,Gstreamer,Gstreamer 1.0,我的应用程序需要多次重新启动gstreamer管道。 但是在将管道设置为GST_STATE_NULL并在管道上调用unref之后,内存似乎没有被释放。 每次重新启动后,与进程相关的内存不断增加 我仅使用videotestsrc fakesink元素就可以重现问题,如下所示: //g++-Wall testpage_Simple.cpp-o testpage_Simple$(pkg config--cflags--libs gstreamer-1.0) #包括 GstElement*管道; Gst
#包括
GstElement*管道;
GstElement*src;
GstElement*水槽;
无效clearPipeline(){
//g_print(“clearPipeline”);
gst\元素\集合\状态(管道,gst\状态\空);
gst_对象_unref(管道);
}
void createPipeline(){
管道=gst_管道_新(“管道播放”);
src=gst元素工厂制造(“videotestsrc”,“来源”);
水槽=商品及服务税(gst)元件、工厂制造(“假冒油墨”、“水槽”);
gst_bin_add_many(gst_bin(管道)、src、sink、NULL);
如果(gst_元素_链接(src,接收器)!=TRUE){
g_printerr(“src,接收器无法链接。\n”);
}
gst元素设置状态(管道、gst状态);
}
gint干管(gint-argc,gchar*argv[])
{
gst_init(空,空);
系统(“gst-launch-1.0——gst版本”);
g_打印(“开始测试-”);
//对于(int i=1;iYou应该取消src
和sinkTohank you@sparik。我没有明确取消src和sink,因为它们是bin“pipelinePlay”的一部分,所以取消管道取消src和sink。但我尝试了您建议的更改,并得到以下错误。-取消管道后-“GStreamer-CRITICAL:gst\u-object\u-unref:assertion'((GObject*)object)->ref\u count>0'失败”-在取消刷新管道之前-“GStreamer-CRITICAL:尝试处理对象“src”,但它仍然有一个父对象“pipelinePlay”。您需要让父对象管理对象,而不是直接取消刷新对象“对不起,你似乎是对的。管道拥有元素的所有权。你应该取消取消取消src
和sink
touthank you@sparik。我没有明确取消取消取消src和sink,因为它们是bin“pipelinePlay”的一部分。”,所以取消记录管道取消记录src和sink。但我确实尝试了您建议的更改,并出现以下错误。-在取消记录管道之前-“GStreamer CRITICAL:gst\u object\u unref:assertion'((GObject*)object)->ref\u count>0'失败”-在取消记录管道之前-“GStreamer CRITICAL:尝试处理对象“src”,但它仍然有一个父对象”“pipelinePlay”。您需要让父级管理对象,而不是直接取消对象的签名“对不起,似乎您是对的。管道拥有元素的所有权
#include <gst/gst.h>
GstElement *pipeline;
GstElement *src;
GstElement *sink;
void clearPipeline () {
// g_print ("clearPipeline ");
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
}
void createPipeline () {
pipeline = gst_pipeline_new ("pipelinePlay");
src = gst_element_factory_make ("videotestsrc", "source");
sink = gst_element_factory_make ("fakesink", "sink");
gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
if (gst_element_link (src, sink)!= TRUE) {
g_printerr ("src, sink could not be linked.\n");
}
gst_element_set_state (pipeline, GST_STATE_PLAYING);
}
gint main (gint argc, gchar * argv[])
{
gst_init (NULL, NULL);
system("gst-launch-1.0 --gst-version");
g_print ("Start Test - ");
// for (int i=1; i<=10; i++) {
system ("top -b -n 1 | grep testpage | awk '{print $6}'");
createPipeline();
clearPipeline();
// }
g_print ("End of test !! ");
system ("top -b -n 1 | grep testpage | awk '{print $6}'");
gst_deinit();
return 0;
}