DCOP memory leak?
larry.bates at websafe.com
Wed Jan 31 01:03:44 CET 2007
TimDGCB at gmail.com wrote:
> I'm writing a python script for Amarok, I communicate with Amarok
> using DCOP.
> Now, I have to call DCOP very often and I noticed that every time I
> make a DCOP call my program keeps growing in memory size.
> To make sure it was DCOP i wrote the small program below:
> from dcopext import DCOPClient, DCOPApp
> while 0==0:
> AmarokDcopRes = DCOPApp ("amarok", dcop)
> ok, Ms = AmarokDcopRes.player.trackCurrentTimeMs()
> print Ms
> If you run this script and monitor it's memory use you'll see that it
> keeps growing.
> Does anyone know how I can solve this problem?
> Kind regards,
I think you will find the objects are getting created so fast that
garbage collection doesn't have time to clean them up as fast
as you are creating new ones. Since del dcop is not guaranteed
to be "immediate" that won't help.
Q: Can't you create dcop instance outside the loop and reuse it
for every time through the loop?
Q: Can you sleep or something after each loop or do you really
want to peg the CPU checking forever?
Q: How do you ever get out of this infinite loop?
Note: while 0=0 is better written as while 1: and you need a
break somewhere to get out of the loop.
More information about the Python-list