Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • gstreamer gstreamer
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 938
    • Issues 938
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 440
    • Merge requests 440
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GStreamerGStreamer
  • gstreamergstreamer
  • Issues
  • #539
Closed
Open
Issue created Apr 21, 2020 by Krithika V@KrithikaV

Memory not freed after gstreamer pipeline set to GST_STATE_NULL

My application requires gstreamer pipeline to be restarted multiple times. But after setting the pipeline to GST_STATE_NULL and calling unref on the pipeline, memory appears to be not freed. After every restart, the memory associated with the process keeps increasing.

I was able to reproduce the problem with just videotestsrc-fakesink elements as given below :

//g++ -Wall testpage_Simple.cpp -o testpage_Simple $(pkg-config --cflags --libs gstreamer-1.0)

#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; 
} 

Sample output on Ubuntu 19.04 (showing only RES column value from top command for this process): GStreamer Core Library version 1.16.1
Start Test - 7140
End of test !! 8504

We observed similar memory trend on Ubuntu 18.04 with gstreamer 1.12.4 as well.

Is this the expected behaviour or did I miss something in cleaning up the pipeline ?

Assignee
Assign to
Time tracking