On Thu, 2008-02-07 at 14:53 -0500, Kashyap Ashwin wrote: > I made python print the #refs for alpha and that seems to be increasing > for no reason. My guess is that it was not decremented after sine_func > completed. I don't know much about clutter...
the alpha functions never increment the reference count of the alpha object; the alpha object does not take a reference on the behaviour: it's the other way around, so there's no reference cycle: behaviour +---> takes reference on ClutterAlpha +----> takes reference on ClutterTimeline but the GObject side (and, implicitly, the Clutter side) of things is cleared: there are no circular references to break, and the reference count is correct. > class AnimatedLabel(): > > def __init__(self): > print 'INIT %s' % self > self.label = clutter.Label() > self.timeline = clutter.Timeline(duration=1000) > self.timeline.set_loop(True) > self.alpha = clutter.Alpha(self.timeline, clutter.ramp_func) > self.behaviour = clutter.BehaviourDepth(alpha=None, > depth_start=0, depth_end=200) > self.behaviour.apply(self.label) > self.timeline.start() > > def __del__(self): > print '#alph:', sys.getrefcount(self.alpha) > print '#beh:', sys.getrefcount(self.behaviour) > print '#tim:', sys.getrefcount(self.timeline) > del self.alpha > del self.behaviour > print 'DEL %s' % self > > > Output: > INIT <__main__.AnimatedLabel instance at 0xb65cee4c> > #alph: 481 eeek. each python wrapper around alpha functions from the clutter module is nothing more than a glorified function call: py_alpha = PyTuple_GetItem (args, 0); if (py_alpha && pygobject_check (py_alpha, &PyClutterAlpha_Type)) { alpha = CLUTTER_ALPHA (pygobject_get (py_alpha)); return PyInt_FromLong (clutter_ramp_func (alpha, NULL)); } pygobject_get() does not increase the reference count (last time I checked), and this is confirmed by the GObject reference count; PyTuple_GetItem() is defined as: PyObject* PyTuple_GetItem( PyObject *p, Py_ssize_t pos) Return value: Borrowed reference. so it shouldn't increase the python object reference count either. > #alph: 2511 again: eeek. > #beh: 2 > #tim: 2 > > > Obviously alpha is never freed! BTW if you look at alpha.__grefcount__, > that seems to be sane (and it does not agree with python ref count only > for alpha). this is all very dodgy. ciao, Emmanuele. -- Emmanuele Bassi, OpenedHand Ltd. Unit R, Homesdale Business Centre 216-218 Homesdale Rd., Bromley - BR12QZ http://www.o-hand.com -- To unsubscribe send a mail to [EMAIL PROTECTED]