After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 709397 - Gtk.TreeModel.get_value leaks memory
Gtk.TreeModel.get_value leaks memory
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: general
3.10.x
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2013-10-03 22:35 UTC by Cole Robinson
Modified: 2013-10-04 11:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Simple reproducer script (1.18 KB, text/plain)
2013-10-03 22:35 UTC, Cole Robinson
Details

Description Cole Robinson 2013-10-03 22:35:07 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
Comment 1 Simon Feltman 2013-10-04 01:32:58 UTC
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.
Comment 2 Simon Feltman 2013-10-04 02:45:41 UTC
Pushed to both 3.10 and 3.11
Comment 4 Cole Robinson 2013-10-04 11:51:43 UTC
You're the man, thanks Simon!