2

I am creating a tool using pyQt but facing memory leakage issue.

When I delete an object containing python and pyQt member variables from UI using my own trash, it calls up the destructor of the respective class. But when I run 'top' command from terminal the memory is not freed and keeps on occupying as long as I use the applications and finally crashes up.

Ivan Ferić
  • 4,725
  • 11
  • 37
  • 47
Nitish Jain
  • 206
  • 2
  • 5
  • 2
    Show us a small program that demonstrates the issue. – Janne Karila Feb 13 '13 at 08:01
  • Usually these problems occur because the C++ object is still being referenced to. If you've added the QObject to a QT class hierarchy, it won't be destroyed until the referencer is deleted, or the reference is broken. I'm puzzled what you mean by destructor - is this actually the C++ destructor or Python __del__? – xioxox Feb 13 '13 at 10:11
  • The destructor is the python del method. Yes i too find that the QObject is not deleting due to some issue. But I am not able to find a way how to delete the same and free memory. – Nitish Jain Feb 14 '13 at 07:39
  • why not share some codes? i am certain there is a reference somewhere to the object – Ajayi Oluwaseun Emmanuel May 07 '16 at 16:27
  • Explicit memory management while using Python generally indicates a more underlying issue. I think a more clear example of your use case and some minimal code to demonstrate the issue would be very helpful here. – theorifice Dec 04 '16 at 14:53

1 Answers1

1

I already faced this problem before. I used this approach and it worked fine for me:

widget.setParent(None)
widget.deleteLater()

Hope it helps!

EDIT:

Also see this one please: https://stackoverflow.com/a/30245816/6337523

Community
  • 1
  • 1
Szabolcs
  • 3,990
  • 18
  • 38