GNOME Bugzilla – Bug 616655
Gtk2::Gdk::Window destruction doesn't work correctly
Last modified: 2010-11-23 20:26:45 UTC
Created attachment 159437 [details] test case When creating a child Gtk2::Gdk::Window, I get an error when closing the program. Either "Gdk-WARNING **: losing last reference to undestroyed window" if I didn't call destroy on the child gdkwindow, or "Attempt to free unreferenced scalar: SV 0x9a8ca78, Perl interpreter: 0x9a6b008." if I called destroy on the child gdkwindow. (see attached test case) Looking further, creating and destroying child gdkwindows continuously leaks some memory, and doing the same with toplevel gdkwindows ends up with an error. Replacing "GdkWindow_noinc * gdk_window_new" by "GdkWindow * gdk_window_new" in xs/GdkWindow.xs seems to fix it, though I don't know enough about gtk and the bindings to be sure it's the correct fix.
Yes. It happens to a toplevel window too, per attached toplevel.pl. Removing the _noinc from gdk_window_new() fixes it for me too. But I don't think there's a memory leak. If you run some main loop iterations per attached noleak.pl then the memory is steady. I imagine it's notify events or whatever coming back from the server. Is a GdkWindow kept alive by it's place in the "list_toplevels" thingie, or by its parent when not a toplevel? So if you clear your perl scalar before the it's removed from there then no problem, but if the scalar lasts after that then there's a missing g_object_ref() for that scalar.
Created attachment 169634 [details] failing program
Created attachment 169635 [details] loop program which doesn't leak memory, but does provoke the _noinc problem
Yes, I think you are both correct. The current "transfer none" annotation also agrees. So I committed the suggested change to master and the stable-1-22 branch. Thanks for the report.