DCOP memory leak?

T

TimDGCB

Hello,

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:
dcop=DCOPClient()
dcop.attach()
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,

Tim
 
J

jean-michel bain-cornu

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:
dcop=DCOPClient()
dcop.attach()
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.

It's probably silly, but what's about 'del dcop' as the last line of
your loop ?
 
L

Larry Bates

Hello,

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:
dcop=DCOPClient()
dcop.attach()
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,

Tim

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.

-Larry
 
T

TimDGCB

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.

-Larry
Hi,

Thanks for the quick response.

The code I posted is not my actual program and was only to demonstrate
my problem. The complete program I'm writing uses QT and so the loop
is replaced by a Timer event.
I tried out the suggestion. I had already tried the del dcop
instruction, so I knew that wasn't it. I also placed the DCOP variable
outside my loop but that didn't help either.
What I did notice that my program only grew in memory use when the
'ok, Ms = AmarokDcopRes.player.trackCurrentTimeMs() ' code was
executed (or any other function using the AmarokDcopRes variable like
'ok, volume = AmarokDcopRes.player.getVolume()' )
Then I also tried to make my take a pause of a second in the loop but
this also didn't help, the program was still growing in memory use (a
lot slower though but I don't call that a solution)

So if you have any more ideas let me know. I'll keep on trying

Kind regards,

Tim
 
D

David Boddie

The code I posted is not my actual program and was only to demonstrate
my problem. The complete program I'm writing uses QT and so the loop
is replaced by a Timer event.
I tried out the suggestion. I had already tried the del dcop
instruction, so I knew that wasn't it. I also placed the DCOP variable
outside my loop but that didn't help either.

You might get a precise answer to your question if you send a message
to the PyQt/PyKDE mailing list:

http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

The original authors and contributors of various Python DCOP modules
read that list, so there's a chance they can either solve your problem
or offer some advice on how to work around it.
What I did notice that my program only grew in memory use when the
'ok, Ms = AmarokDcopRes.player.trackCurrentTimeMs() ' code was
executed (or any other function using the AmarokDcopRes variable like
'ok, volume = AmarokDcopRes.player.getVolume()' )

Do you find the same problem with other DCOP interfaces?

David
 
T

TimDGCB

You might get a precise answer to your question if you send a message
to the PyQt/PyKDE mailing list:

http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

The original authors and contributors of various Python DCOP modules
read that list, so there's a chance they can either solve your problem
or offer some advice on how to work around it.


Do you find the same problem with other DCOP interfaces?

David

Hi David,

I did tried out some other DCOP calls from other programs and I have
the same problem.

I followed your suggestion to subcribe and poste to the pyKDE mailing
list. I hope they can help me there.

Thanks,

Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top