python - pyqt: Memory Usage -


i have program , in it, creates tabs, , every time create 1 memory usage goes up, when close tab out memory doesn't go down. wondering, normal, , there can it? here code closing out tabs:

def removetab(self, index):    text[index].deletelater()   del text[index] # text box    # reorganize dict   last = -1   key in sorted(text):     if last+1 != key:       text[key-1] = text[key]       del text[key]     last += 1    self.tab_widget.setcurrentindex(index)   widget = self.tab_widget.currentwidget()   self.tab_widget.removetab(index)  # remove tab   widget.deletelater()   del widget 

to put crudely:

  1. the amount of memory available python application can grow during lifetime, can never fully shrink started.

  2. there no way force python release unused memory system.

so best can try manage amount memory grows. 1 obvious way delete unneeded objects, newly created objects can re-use memory has been allocated.

but if application seems unable re-use memory? either means objects not being deleted cleanly (i.e. there references them being kept somewhere), or, less likely, there underlying memory leak in pyqt/qt.

tracking down references kept objects can quite tricky (to least). common "hiding places" in pyqt signals connected using lambda (or functools.partial), or monkey-patched protected methods. there no hard-and-fast rules finding them.

as stands, example code in question not seem have places references "hiding". if memory usage goes "every time" tab created (as op claims), problems must lie elsewhere in application - or more precise, problems lie in how objects created, rather in how deleted.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -