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 515706 - [ximagesrc] Memory leak when XDamage support is available
[ximagesrc] Memory leak when XDamage support is available
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Linux
: Normal blocker
: 0.10.7
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-02-11 08:16 UTC by Sebastian Dröge (slomo)
Modified: 2008-02-12 11:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
ximagesrc patch (1.17 KB, patch)
2008-02-11 23:43 UTC, Jan Schmidt
none Details | Review
ximage-buffer.diff (1.13 KB, patch)
2008-02-12 11:01 UTC, Sebastian Dröge (slomo)
none Details | Review

Description Sebastian Dröge (slomo) 2008-02-11 08:16:27 UTC
Hi,
currently the damage_copy_gc field of the instance struct of ximagesrc is filled with a GC if XDamage support is available. Unfortunately this is never freed again which results in a memory leak.

I have no idea how to fix it though, calling XFreeGC on it in finalize and before setting it (if != NULL) gives an X error.

==32362== 112 bytes in 1 blocks are definitely lost in loss record 15,320 of 16,085
==32362==    at 0x4024AB8: malloc (vg_replace_malloc.c:207)
==32362==    by 0x63D5274: XCreateGC (in /usr/lib/libX11.so.6.2.0)
==32362==    by 0x6C32C4B: gst_ximage_src_open_display (gstximagesrc.c:175)
==32362==    by 0x4A7004B: gst_base_src_start (gstbasesrc.c:2288)
==32362==    by 0x4A7161B: gst_base_src_activate_push (gstbasesrc.c:2505)
==32362==    by 0x4086BA6: gst_pad_activate_push (gstpad.c:896)
==32362==    by 0x4087094: gst_pad_activate_default (gstpad.c:569)
==32362==    by 0x4087122: gst_pad_set_active (gstpad.c:658)
==32362==    by 0x406DEEA: activate_pads (gstelement.c:2509)
==32362==    by 0x407A466: gst_iterator_fold (gstiterator.c:503)
==32362==    by 0x406D961: iterator_activate_fold_with_resync (gstelement.c:2541)
==32362==    by 0x406D9FD: gst_element_pads_activate (gstelement.c:2577)
==32362==    by 0x406DD60: gst_element_change_state_func (gstelement.c:2651)
==32362==    by 0x4A736CC: gst_base_src_change_state (gstbasesrc.c:2642)
==32362==    by 0x406A476: gst_element_change_state (gstelement.c:2425)
==32362==    by 0x406A9C2: gst_element_set_state_func (gstelement.c:2375)
==32362==    by 0x4069522: gst_element_set_state (gstelement.c:2278)
==32362==    by 0x8049507: test_state_changes_up_and_down_seq (states.c:120)
==32362==    by 0x4031F0F: srunner_run_all (in /home/slomo/projects/gstreamer/head/gstreamer/libs/gst/check/.libs/libgstcheck-0.10.so.0.15.0)
==32362==    by 0x402CFD9: gst_check_run_suite (gstcheck.c:520)
Comment 1 Jan Schmidt 2008-02-11 15:40:22 UTC
from the stack-trace, the complementary place to close it would be in the stop() function, before we call ximageutil_xcontext_clear which will release the xserver display connection.
Comment 2 Jan Schmidt 2008-02-11 23:43:08 UTC
Created attachment 105000 [details] [review]
ximagesrc patch

This patch seems to work for me.
While making it, I'm not actually sure what the 'damage_region' variable is for - it doesn't seem to be used at all after it is created. It isn't passed to anything .
Comment 3 Sebastian Dröge (slomo) 2008-02-12 05:32:21 UTC
Works fine for me and fixes the leak... but I also have no idea if damage_region is useful at all and asked that myself while looking at it :)
Comment 4 Sebastian Dröge (slomo) 2008-02-12 11:00:18 UTC
Ok, but ximagesrc does not work at all for me, only in the states test :)

gst-launch-0.10 ximagesrc ! ffmpegcolorspace ! fakesink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
X Error of failed request:  176
  Major opcode of failed request:  158 (DAMAGE)
  Minor opcode of failed request:  3 (XDamageSubtract)
  Serial number of failed request:  30
  Current serial number in output stream:  31
Comment 5 Sebastian Dröge (slomo) 2008-02-12 11:01:12 UTC
Created attachment 105028 [details] [review]
ximage-buffer.diff

This patch is also needed... should be obvious.


(the above error can be stopped by using use-damage=false)
Comment 6 Jan Schmidt 2008-02-12 11:15:21 UTC
Both patches committed.

I don't get the Damage error with the previous ximagesrc release, that appears to be a regression.

Filing a new bug to fix that.