<div dir="ltr"><span style="color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-size:14px;line-height:17.8048000335693px">I am using the following code to show slide show via gstreamer (for simplicity, the following just re-shows the same image every second):</span><br><div><span style="color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-size:14px;line-height:17.8048000335693px"><br></span></div><div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"># python testcase.py large-image.jpg</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">import gi</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">gi.require_version("Gst", "1.0")</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">from gi.repository import GLib, GObject, Gst</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">import sys</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">class Player(object):</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">    def __init__(self):</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        Gst.init(None)</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        self.pipeline = Gst.Pipeline()</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        self.source_bin = None</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        self.sink = Gst.ElementFactory.make("xvimagesink")</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        self.pipeline.add(self.sink)</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">    def play(self):</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        self._load_next_file()</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">    def _load_next_file(self):</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        self.pipeline.set_state(Gst.State.READY)</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        if self.source_bin is not None:</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">            self.pipeline.remove(self.source_bin)</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">            self.source_bin.set_state(Gst.State.NULL)</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        self.source_bin = self._create_image_source_bin()</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        self.pipeline.add(self.source_bin)</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        self.source_bin.link(self.sink)</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        self.source_bin.sync_state_with_parent()</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        self.pipeline.set_state(Gst.State.PLAYING)</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">    def _create_image_source_bin(self):</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        src = Gst.ElementFactory.make("filesrc")</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        src.set_property("location", sys.argv[1])</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        decoder = Gst.ElementFactory.make("jpegdec")</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        freezer = Gst.ElementFactory.make("imagefreeze")</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        GObject.timeout_add(1000, self._on_image_timeout)</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        bin = Gst.Bin()</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        bin.add(src)</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        bin.add(decoder)</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        bin.add(freezer)</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        bin.add_pad(Gst.GhostPad.new("src", freezer.get_static_pad("src")))</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        src.link(decoder)</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        decoder.link(freezer)</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        return bin</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">    def _on_image_timeout(self):</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        self._load_next_file()</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">        return False</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">p = Player()</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">p.play()</span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px">GObject.MainLoop().run()</span></font></div></div><div style><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div><div style><span style="color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-size:14px;line-height:17.8048000335693px">Memory usage increases every second and never decreases; looks like, old source_bin</span><span style="color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-size:14px;line-height:17.8048000335693px"> is not being freed when new one is being created. Is it a bug in gstreamer/python-gstreamer or am I missing something?</span><font color="#000000" face="Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style="font-size:14px;line-height:17.8048000335693px"><br></span></font></div></div>