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 651170 - Memory leak: Circular reference in GtkMenuItem
Memory leak: Circular reference in GtkMenuItem
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: GtkMenu
2.24.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2011-05-26 17:02 UTC by Radu C
Modified: 2018-04-15 00:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proof of leak (797 bytes, application/x-compressed-tar)
2011-05-26 17:02 UTC, Radu C
Details

Description Radu C 2011-05-26 17:02:40 UTC
Created attachment 188685 [details]
Proof of leak

I have an application (glipper) in which I update the menu quite frequently, and I noticed a slow rise in memory usage while running, and I tracked it down to GtkMenuItem.

I noticed this in Ubuntu 10.10 (gtk 2.22.0), but since there were only a few days to 11.04, I decided to wait. I can also confirm the bug in Ubuntu 11.04 (gtk 2.24.4).

Please note that this leak happens only if the GtkMenuItem has a label. There's no leak if it doesn't have a label.

Proof code attached. Glipper is written in Python (with PyGTK), so the first thing I did to track this down was to create the simplest python program that demonstrates the bug. Using my friend Google, I managed to write the same code in Vala and compile it to C (to confirm it doesn't do anything else but create and destroy GtkMenuItem objects). The leak still exists after compiling the C source.

How to test:
1. Start "top", sort by memory (<O> <n> <enter>)
2. Run either the python script or the binary resulting from the Vala or C sources.
3. Watch the program rise in "top". It will take less than a minute to become noticeable.

Reading the source, unless I missed something, I should have at most one GtkMenuItem at any time, so the memory usage should not increase. So far, the workaround is to explicitly destroy the GtkMenuItem, but it's not that convenient.

There may be a similar, but not as evident issue in GtkMenu after removing a GtkMenuItem, but I haven't pursued that possible problem yet. I'll file another bug report if I can confirm the GtkMenu leak it's not just my imagination.
Comment 1 Matthias Clasen 2018-02-10 04:59:38 UTC
We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO if they haven't seen activity in more than a year. If this issue is still important to you and still relevant with GTK+ 3.22 or master, please reopen it and we will migrate it to gitlab.
Comment 2 Matthias Clasen 2018-04-15 00:10:25 UTC
As announced a while ago, we are migrating to gitlab, and bugs that haven't seen activity in the last year or so will be not be migrated, but closed out in bugzilla.

If this bug is still relevant to you, you can open a new issue describing the symptoms and how to reproduce it with gtk 3.22.x or master in gitlab:

https://gitlab.gnome.org/GNOME/gtk/issues/new