[PyKDE] Memory leak when overriding QListViewItem.key()?

Phil Thompson phil at river-bank.demon.co.uk
Sat Aug 17 15:13:01 BST 2002


Fredrik Juhlin wrote:

> Hi!
> 
> While trying to figure out the best way to control the sorting of a
> QListView, I stumbled over what seems to be some sort of memory leak
> when I override QlistViewItem.key().
> 
> When I run the code below, my python process uses aprox 58MB. If I
> uncomment the key() method in MyListItem, it uses 150MB.
> 
> If there's a reasonable explanation for this that eludes me, or if I'm
> simply doing something horribly wrong, please let me know :)
> 
> //Fredrik
> 
> #!/usr/bin/env python
> 
> import qt
> import sys
> 
> class MyListItem(qt.QListViewItem):
>     def key(self, column, ascending):
>         return qt.QListViewItem.key(self, column, ascending)
>     pass
>         
> 
> if __name__ == '__main__':
>     app = qt.QApplication(sys.argv)
>     lw = qt.QListView()
>     lw.addColumn('Mepp')
>     for x in xrange(5000):
>         li = MyListItem(lw)
>         li.setText(0, str(x))
> 
>     app.setMainWidget(lw)
>     lw.show()
>     app.exec_loop()


What about MyListItem.__init__()?

Phil




More information about the PyQt mailing list