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 694860 - gtk_init_check causes memory leak on sys.argv
gtk_init_check causes memory leak on sys.argv
Product: pygobject
Classification: Bindings
Component: introspection
Git master
Other Linux
: Low minor
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks: 693111
Reported: 2013-02-28 12:05 UTC by Martin Pitt
Modified: 2013-10-11 06:31 UTC
See Also:
GNOME target: ---
GNOME version: ---

Description Martin Pitt 2013-02-28 12:05:38 UTC
I noticed this memory leak:

G_SLICE=debug-blocks valgrind --tool=memcheck --leak-check=full --show-possibly-lost=no python3 -c 'import sys; from gi.module import get_introspection_module; Gtk=get_introspection_module("Gtk"); Gtk.init_check(sys.argv)'

==15541== 51 bytes in 1 blocks are definitely lost in loss record 2,467 of 7,296
==15541==    at 0x4C2CD7B: malloc (in /usr/lib/valgrind/
==15541==    by 0x439D12: PyUnicode_New.part.27 (unicodeobject.c:1016)
==15541==    by 0x4426B9: PyUnicode_FromUnicode (unicodeobject.c:967)
==15541==    by 0x4AF1A0: PySys_SetArgvEx (sysmodule.c:1801)
==15541==    by 0x4BE11D: Py_Main (main.c:669)
==15541==    by 0x419AF8: main (python.c:66)

It doesn't generally seem to apply to inout arguments; if I don't call this with sys.argv, but instead with a custom list, this leak doesn't happen:

G_SLICE=debug-blocks valgrind --tool=memcheck --leak-check=full --show-possibly-lost=no python3 -c 'from gi.module import get_introspection_module; Gtk=get_introspection_module("Gtk"); a = ["a", "b"]; print(Gtk.init_check(a))'
Comment 1 Simon Feltman 2013-10-11 06:31:53 UTC
I was unable to reproduce any of the noted leak with what is currently in
master. This was most likely fixed with commits that has been going in for bug