Hi,

I have a Clutter based Python application that leaks a lot of memory.
Objects instantiated from my python classes inheriting from clutter
never seem to get freed.

In some cases I could work around the worst memory leaks by explicitly
calling self.destroy() but this just lead me into more troubles later.

I created a small example (modified from examples/videosink.py) that
demonstrates the memory leak.  Key press event on the stage window
will assign over the previously created Player object which I assume
should trigger the old one being garbage collected at some point.
However there seems to be some references that keep the objects in
memory forever.

After running this loop couple of times the process reserves all my
memory (be careful not getting your computer completely unresponsive).


import clutter
from clutter import cluttergst
import gst

myplayer = None

class Player(clutter.Texture):

    def __init__(self):
        super(Player, self).__init__()

        self.pipeline = gst.Pipeline()
        self.src = gst.element_factory_make("audiotestsrc")
        self.goom = gst.element_factory_make("goom")
        self.colorspace = gst.element_factory_make("ffmpegcolorspace")
        self.sink = cluttergst.VideoSink(self)

        self.pipeline.add(self.src, self.goom, self.colorspace, self.sink)
        gst.element_link_many(self.src, self.goom, self.colorspace, self.sink)
        self.pipeline.set_state(gst.STATE_PLAYING)



def restart_player(a,b):
    global myplayer
    if myplayer:
        print 'removing old player: %s' % myplayer
        stage.remove(myplayer)
    myplayer = Player()
    print 'created new player: %s' % myplayer
    myplayer.show()
    stage.add(myplayer)



stage = clutter.stage_get_default()
stage.set_size(320,240)
stage.connect('key-press-event', restart_player)
stage.show_all()
clutter.main()



In some cases I could get away by reusing the objects between
switching the screens in my applications but this complicates the
logic a lot.

I must be missing something obvious...  All help is appreciated! :)

--
Tero
-- 
To unsubscribe send a mail to [EMAIL PROTECTED]

Reply via email to