DCOP memory leak?

Discussion in 'Python' started by TimDGCB@gmail.com, Jan 30, 2007.

  1. Guest

    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
     
    , Jan 30, 2007
    #1
    1. Advertising

  2. > 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 ?
     
    jean-michel bain-cornu, Jan 30, 2007
    #2
    1. Advertising

  3. Larry Bates Guest

    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
     
    Larry Bates, Jan 31, 2007
    #3
  4. Guest

    On 31 jan, 01:03, Larry Bates <> wrote:
    > 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
     
    , Jan 31, 2007
    #4
  5. David Boddie Guest

    On Jan 31, 6:46 pm, "" <> 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
     
    David Boddie, Jan 31, 2007
    #5
  6. Guest

    On 31 jan, 19:51, "David Boddie" <> wrote:
    > On Jan 31, 6:46 pm, "" <> 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
     
    , Jan 31, 2007
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric Williams

    PyQt and DCOP Documentation

    Eric Williams, Nov 10, 2003, in forum: Python
    Replies:
    6
    Views:
    456
    Fedor Sumkin
    Nov 11, 2003
  2. Replies:
    1
    Views:
    300
    R. C. James Harlow
    May 8, 2005
  3. Replies:
    2
    Views:
    328
  4. Jeffrey Barish

    Using DCOP from Python

    Jeffrey Barish, Dec 18, 2006, in forum: Python
    Replies:
    1
    Views:
    539
    David Boddie
    Dec 19, 2006
  5. News123
    Replies:
    0
    Views:
    504
    News123
    Nov 9, 2008
Loading...

Share This Page