首页| 论坛| 消息

标题:为什么我的窗口关闭后也不释放系统资源!
作者:buben
日期:2006-05-24 09:45
内容:

我也遇到与seraphliu类似的问题!程序是用python写的,用Qt做界面,做了一个显示数据库表的表格窗口。但是当关闭这个表格窗口时,内存并不释放。据说python有自己的内存回收功能,不用程序员操心。但如果python不释放,该怎么办?下面是我的部分python程序:
...
self.connect(self.applyBtn,SIGNAL("clicked()"),self.showAll)
...
def showAll(self):
if self.filename:
self.a=Form1(self,value=self.filename)
self.a.show()

class Form1(QDialog):
def __init__(self, parent=None, value=None):
QDialog.__init__(self, parent, "View Whole Table")
self.value=value
self.table1 = QTable(self,"table1")
self.table1.setGeometry(QRect(0,0,800,560))
self.table1.setMinimumWidth(200)

mydb=MySQLdb.Connect(host="localhost", db="test",user="root",passwd="root")
mycursor=mydb.cursor()
stmt="select max(index) from %s"% str(self.value)
mycursor.execute(stmt)
result = mycursor.fetchone()
numEx=result[0]
self.table1.setNumRows(numEx)

stmt="describe %s"% str(self.value)
mycursor.execute(stmt)
result = mycursor.fetchall()
numCo=len(result);
self.table1.setNumCols(numCo)


self.languageChange()
hheader=self.table1.horizontalHeader()

stmt="select * from %svartype"% str(self.value)
mycursor.execute(stmt)
result = mycursor.fetchall()
i=0
jj=0
..

回复 发表
主题 版块