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 578493 - vte.Terminal.set_background_image memory leak
vte.Terminal.set_background_image memory leak
Status: RESOLVED OBSOLETE
Product: vte
Classification: Core
Component: general
0.20.x
Other All
: Normal normal
: ---
Assigned To: VTE Maintainers
VTE Maintainers
[fixed-next]
Depends on:
Blocks:
 
 
Reported: 2009-04-09 14:29 UTC by NAKAMURA Yoshitaka
Modified: 2014-03-27 18:49 UTC
See Also:
GNOME target: ---
GNOME version: 2.25/2.26


Attachments
Fix memleak (534 bytes, patch)
2009-04-09 14:31 UTC, NAKAMURA Yoshitaka
reviewed Details | Review
vte-memleak.py (407 bytes, text/plain)
2009-04-10 13:05 UTC, NAKAMURA Yoshitaka
  Details
Do not ref the pixbuf in the cache (395 bytes, patch)
2010-08-11 13:11 UTC, Nick Schermer
none Details | Review
Do not ref in cache and free on finalize (755 bytes, patch)
2010-08-11 13:33 UTC, Nick Schermer
none Details | Review
fix a memory leak in cache (700 bytes, patch)
2010-09-13 03:02 UTC, Eiichi Sato
none Details | Review

Description NAKAMURA Yoshitaka 2009-04-09 14:29:16 UTC
Please describe the problem:
vte.Terminal.set_background_image does not release pixbuf objects.
So python's gc can't free the objects and memory usage keep growing.

Steps to reproduce:
1. Create vte.Terminal instance
2. Call set_background_image repeatedly
3. 


Actual results:
Memory usage keep growing

Expected results:
Memory usage not grow

Does this happen every time?
yes

Other information:
Comment 1 NAKAMURA Yoshitaka 2009-04-09 14:31:53 UTC
Created attachment 132409 [details] [review]
Fix memleak

This patch fix the problem.
But I'm not a C programmer and I don't know what I do.
Comment 2 Christian Persch 2009-04-09 17:06:44 UTC
I don't think this patch is correct. In the saturation != 1.0 case, we create a new ref, so for symmetry alone we have to ref source_pixbuf here. The code below that unrefs the pixbuf again.

Can you please attach a testcase to reproduce the leak? Or a valgrind log at least?
Comment 3 NAKAMURA Yoshitaka 2009-04-10 13:05:02 UTC
Created attachment 132459 [details]
vte-memleak.py

This python script reproduce the problem.
Comment 4 Christian Persch 2009-04-10 13:31:20 UTC
Only leak in the testcase that's background related:

==9626== 108 (16 direct, 92 indirect) bytes in 1 blocks are definitely lost in loss record 74 of 202
==9626==    at 0x4024D2E: malloc (vg_replace_malloc.c:207)
==9626==    by 0x4024EAF: realloc (vg_replace_malloc.c:429)
==9626==    by 0x46A564D: g_realloc (gmem.c:170)
==9626==    by 0x461CE8F: g_object_weak_ref (gobject.c:1983)
==9626==    by 0x461D159: g_object_add_weak_pointer (gobject.c:2050)
==9626==    by 0x598F480: vte_bg_cache_add (vtebg.c:443)
==9626==    by 0x598FD38: vte_bg_get_pixmap (vtebg.c:669)
==9626==    by 0x59925C0: _vte_pangocairo_set_background_image (vtepangocairo.c:872)
==9626==    by 0x5990AC9: _vte_draw_set_background_image (vtedraw.c:240)
==9626==    by 0x598698A: vte_terminal_background_update (vte.c:12472)
==9626==    by 0x598A193: update_repeat_timeout (vte.c:14073)
==9626==    by 0x469FECD: g_timeout_dispatch (gmain.c:3253)
==9626==    by 0x469C9D5: g_main_dispatch (gmain.c:1814)
==9626==    by 0x469DEAD: g_main_context_dispatch (gmain.c:2367)
==9626==    by 0x469E401: g_main_context_iterate (gmain.c:2448)
==9626==    by 0x469EBE8: g_main_loop_run (gmain.c:2656)
==9626==    by 0x4B3D84F: gtk_main (gtkmain.c:1204)
Comment 5 Nick Schermer 2010-08-11 13:11:58 UTC
Created attachment 167594 [details] [review]
Do not ref the pixbuf in the cache

The leak is somewhere else; the cache item refs the pixbuf too which is wrong (weak ref will never work).
Comment 6 Nick Schermer 2010-08-11 13:33:06 UTC
Created attachment 167597 [details] [review]
Do not ref in cache and free on finalize

Same as previous patch, but also unref the bg in finalize.
Comment 7 Behdad Esfahbod 2010-08-11 16:03:21 UTC
ChPe, can you review this please?
Comment 8 Nick Schermer 2010-08-11 17:07:47 UTC
Err in finalize it should be terminal->pvt instead of pvt, sorry.
Comment 9 Christian Persch 2010-08-11 17:10:43 UTC
(In future, please use git format-patch, or git bz, when attaching patches.)
Comment 10 Eiichi Sato 2010-09-13 03:02:08 UTC
Created attachment 170111 [details] [review]
fix a memory leak in cache

This bug seems still not fixed in HEAD.

I partly fixed it as in my attachment.
This is basically the same as what Nick did in his patch in #6.
The difference i think is, i added unref(), but he removed the ref().

Also I didn't noticed nor fixed a memory leak in finalize,
so I think his patch is more complete.
Comment 11 Nick Schermer 2011-01-30 18:39:34 UTC
Tried the patch from Eiichi and it works fine here, all the pixbuf are freed in Xfce terminal with this patch. Can this be applied please?
Comment 12 Nick Schermer 2011-06-19 11:58:22 UTC
This tiny patch is still not applied and vte is still leaking pixbufs...
Comment 13 Christian Persch 2011-06-19 12:06:53 UTC
This is fixed on the vte-next branch and thus will be fixed on master once that branch lands.