GNOME Bugzilla – Bug 709397
Gtk.TreeModel.get_value leaks memory
Last modified: 2013-10-04 11:51:43 UTC
Created attachment 256432 [details] Simple reproducer script This stemmed from several memory leak reports in virt-manager which was leaking like a sieve: https://bugzilla.redhat.com/show_bug.cgi?id=972371 https://bugzilla.redhat.com/show_bug.cgi?id=1004048 We've mostly worked around it, but the main cause seems to be pygobject and set_cell_data_func. Specifically accessing row contents inside the callback. Here's example output from the reproducer: $ python cell_data_leak.py 001) 22280 002) 22540 003) 22804 004) 23068 005) 23068 006) 23332 007) 23596 008) 23596 009) 23860 010) 24124 011) 24124 012) 24388 013) 24652 014) 24652 015) 24916 That's 15 seconds of RSS climbing. Comment out the set_cell_data_func call and it goes away. Comment out the 'foo =' line in the cb and it goes away. $ rpm -q pygobject3 pygobject3-3.10.0-1.fc20.x86_64 Let me know if I can provide any more info
It looks like Gtk.TreeModel.get_value is leaking (not related to set_cell_data_func). If we comment out the cell data func and iterate the model using "get_value" in the timeout. We get a leak as well. def _timeout_cb(): global total global count if total % 1000 == 0: gc.collect() count += 1 print("%.3d) %s" % (count, resource.getrusage(resource.RUSAGE_SELF).ru_maxrss)) total += 100 model = tree.get_model() _iter = model.get_iter(Gtk.TreePath(0)) for i in range(1000): value = model.get_value(_iter, 1) return 1 This may be related to or a dup of bug 693402.
Pushed to both 3.10 and 3.11
https://git.gnome.org/browse/pygobject/commit/?id=073f387 https://git.gnome.org/browse/pygobject/commit/?id=d644cbd
You're the man, thanks Simon!