Garbage collection with QT

Discussion in 'Python' started by Marco Bartel, Jun 8, 2005.

  1. Marco Bartel

    Marco Bartel Guest

    Hello,
    I got a question regarding garbage collection in python when using PyQT.
    How can i safely get rid of an Object instance and delete it
    permanently. For example when having a QTable with a bunch of records
    inside and closing the window hosting it, the memory space will not
    being freed up and when opening it again, the memory usage will grow.
    This ends up, when opening and closing the window serval times, in
    having all swapspace occupied and OS crashing.

    Is there a way, to find out all references to the QMainWindow or its
    hosted QTable, for having a mechanism to destroy them?

    THX
    Marco
    Marco Bartel, Jun 8, 2005
    #1
    1. Advertising

  2. Not all leakage problems caused by qt or python. There is a wrapping
    layer between Qt and Python provided by SIP. Therefore, SIP may cause
    leakages. Also PyQt had a paintCell memory leakage problem several
    months ago. If you're using an old snapshot of PyQt or SIP, that would
    be a problem. Try using the latest snapshots. Also mention your
    versions and problems to the PyKDE mailinglist, it could be more
    helpful.

    If you want to delete C++ objects in Qt, consider using
    QObject.deleteLater() method. IMHO, this won't help.

    Mike
    Mike Tammerman, Jun 8, 2005
    #2
    1. Advertising

  3. Marco Bartel

    Ken Godee Guest

    > Is there a way, to find out all references to the QMainWindow or its
    > hosted QTable, for having a mechanism to destroy them?
    >

    Yes, of coarse, the docs are your friend :)

    QObject::children()
    QObject::removeChild()
    QObject::parent()

    To find all the children for an instance you
    can create a loop.

    An example of a dialog window function
    that cleans it self up ....

    ================================================
    def xdialog(self,vparent,info):

    vlogin = dialogwindow(parent=vparent,modal=1)

    while 1:

    vlogin.exec_loop()

    if vlogin.result() == 0:
    vparent.removeChild(vlogin)
    del vlogin
    break
    ================================================
    Ken Godee, Jun 8, 2005
    #3
    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. Laser Lu

    Garbage Collection and Manage Code?

    Laser Lu, Jan 26, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    702
    Gaurav Khanna [C# MVP]
    Jan 27, 2004
  2. Cheung, Jeffrey Jing-Yen
    Replies:
    3
    Views:
    1,538
    Cheung, Jeffrey Jing-Yen
    Jul 10, 2003
  3. IDoNothing

    Garbage Collection in ASP.NET

    IDoNothing, Jan 9, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    8,354
    cjohn
    Aug 20, 2009
  4. Replies:
    1
    Views:
    433
    mrstephengross
    Jul 25, 2005
  5. Øyvind Isaksen
    Replies:
    1
    Views:
    950
    Øyvind Isaksen
    May 18, 2007
Loading...

Share This Page