python - Pyqt4 processEvents method causing memory leak -
i have code should update gui while calculating showing progress of calculation. know it's bad idea use processevents() method update gui. i should use threads so. however, curious memory leaks come from? if run code number of while loops big enough (like 10^(6)) memory usage jumps 1gb. can explain me?
from pyqt4 import qtgui class calculus: def __init__(self): print "object created" @staticmethod def update_progress(self,value,ui_object): ui_object.settext(qtgui.qapplication.translate("dialog", "progress: %s %%" % value, none)) #memory leak when updating (h=0.0001 , b=1000) qtgui.qapplication.processevents() #update gui pyqt @staticmethod def euler(b,h,progress): #progress ui object, label example. actions_done = 0 actions_number = b * (1./h) #t = t+h. when h = 0.01 need perform t=t+h 100(1/h) times 1. #when t varies 0 b, need multiply 1 * b(end time) #so b * (1/h) number of actions perform scale = actions_number * 0.01 while t <= b: actions_done+=1 progress_value = (actions_done/actions_number)*100 if (actions_done % scale == 0): calculus.update_progress(none,progress_value, progress) t += h
Comments
Post a Comment