Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > DCOP memory leak?

Reply
Thread Tools

DCOP memory leak?

 
 
TimDGCB@gmail.com
Guest
Posts: n/a
 
      01-30-2007
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

 
Reply With Quote
 
 
 
 
jean-michel bain-cornu
Guest
Posts: n/a
 
      01-30-2007
> 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 ?
 
Reply With Quote
 
 
 
 
Larry Bates
Guest
Posts: n/a
 
      01-31-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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

 
Reply With Quote
 
TimDGCB@gmail.com
Guest
Posts: n/a
 
      01-31-2007
On 31 jan, 01:03, Larry Bates <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > 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

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

 
Reply With Quote
 
David Boddie
Guest
Posts: n/a
 
      01-31-2007
On Jan 31, 6:46 pm, "(E-Mail Removed)" <(E-Mail Removed)> wrote:

> 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

 
Reply With Quote
 
TimDGCB@gmail.com
Guest
Posts: n/a
 
      01-31-2007
On 31 jan, 19:51, "David Boddie" <(E-Mail Removed)> wrote:
> On Jan 31, 6:46 pm, "(E-Mail Removed)" <(E-Mail Removed)> wrote:
>
> > 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


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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
module dcop.: How to query running apps? News123 Python 0 11-09-2008 07:45 PM
Using DCOP from Python Jeffrey Barish Python 1 12-19-2006 02:14 PM
dcop module under Python 2.4 qwweeeit@yahoo.it Python 2 10-10-2005 11:10 AM
Controlling kwrite by dcop qwweeeit@yahoo.it Python 1 05-08-2005 01:22 PM
PyQt and DCOP Documentation Eric Williams Python 6 11-11-2003 12:00 PM



Advertisments