고유 한 liststore를 관리하는 사용자 지정 gtk.treeview
래퍼 클래스가 있습니다. 이 클래스에는 목록 저장소의 데이터를 지우고 새 데이터로 덮어 쓰는 자체 메서드가 있습니다. 메모리 사용량을 테스트하기 위해 트리 뷰는 8 개의 열에 50,000 행의 정수를 표시합니다.GtkTreeView treestore 메모리 할당
데이터를 사용하여 목록 저장소를 업데이트하는 함수를 호출 할 때마다 응용 프로그램에서 사용되는 메모리가 증가하는 것으로 나타났습니다. 데이터가 지워진 후에 절대로 다시 작동하지 않습니다.
class TreeViewPrototype(gtk.TreeView):
def __init__(self):
gtk.TreeView.__init__(self)
self.columns = [str, str, str, str, str, str, str, str]
# Initialize Treeview and TreeViewColumns here
# Setup columns
self.liststore = gtk.ListStore(*self.columns)
self.set_model(self.liststore)
def set_list_model(self):
self.liststore.clear()
self.liststore = gtk.ListStore(*self.columns)
# Populate liststore with dummy data
for i in range(50000):
row = []
for j in range(len(self.columns)):
row.append("%d[%d]"%(i,j))
self.liststore.append(row)
내가 새 것으로 liststore을 덮어 쓸 때, 그것은 데이터의 메모리 할당이 결코 모든 호출이 set_list_model 것을 나에게 보인다
은 여기 내 간단한 트 리뷰의 구현입니다. 내가 도대체 뭘 잘못하고있는 겁니까?
어떻게 트리보기의 데이터 저장소로 목록 저장소를 설정합니까? – XORcist
@ möter 죄송합니다. 실수로 제외했습니다. 수정하여 수정했습니다. – Wes
데이터 저장소를 set_list_model의 새 ListStore 인스턴스로 다시 설정하지 않는 것 같습니다. – XORcist