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 768158 - waylandsink : memory leak of gst_wayland_sink_get_caps() and scaler of wldisplay
waylandsink : memory leak of gst_wayland_sink_get_caps() and scaler of wldisplay
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
1.8.2
Other Linux
: Normal critical
: 1.9.90
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 768157 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2016-06-29 02:12 UTC by Hyunil Park
Modified: 2016-09-30 07:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch file (1.52 KB, patch)
2016-06-29 02:24 UTC, Hyunil Park
none Details | Review

Description Hyunil Park 2016-06-29 02:12:33 UTC
There are memory leak.
I find these memory leak by valgrind tool.

First,

Gvalue list and value of gst_wayland_sink_get_caps() are local variable.

&value is allocated on heap memory by g_value_set_string() and &list is allocated on heap memory by gst_value_list_append_value().
but these allocated memory is not free after use.

we need to add g_value_unset (&list) and g_value_unset (&value);

Second,

scaler is not destroyed after use.
We need to add wl_scaler_destroy (self->scaler) on gst_wl_display_finalize().


After fix as below, all definitely issue is removed.

diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c
index 5d59525..02e9a3c 100644
--- a/ext/wayland/gstwaylandsink.c
+++ b/ext/wayland/gstwaylandsink.c
@@ -409,6 +409,8 @@ gst_wayland_sink_get_caps (GstBaseSink * bsink, GstCaps * filter)
     gst_structure_set_value (gst_caps_get_structure (caps, 0), "format", &list);
 
     GST_DEBUG_OBJECT (sink, "display caps: %" GST_PTR_FORMAT, caps);
+    g_value_unset (&list);
+    g_value_unset (&value);
   }
 
   g_mutex_unlock (&sink->display_lock);
diff --git a/ext/wayland/wldisplay.c b/ext/wayland/wldisplay.c
index 3318095..a28e310 100644
--- a/ext/wayland/wldisplay.c
+++ b/ext/wayland/wldisplay.c
@@ -81,6 +81,9 @@ gst_wl_display_finalize (GObject * gobject)
   if (self->shell)
     wl_shell_destroy (self->shell);
 
+  if (self->scaler)
+   wl_scaler_destroy (self->scaler);
+
   if (self->compositor)
     wl_compositor_destroy (self->compositor);


[valgrind log]
==5512== 1,620 (140 direct, 1,480 indirect) bytes in 5 blocks are definitely lost in loss record 2,642 of 2,708
==5512==    at 0x4845750: malloc (vg_replace_malloc.c:296)
==5512==    by 0x49C6EC1: g_malloc (gmem.c:97)
==5512==    by 0x49D67D1: g_slice_alloc (gslice.c:1007)
==5512==    by 0x49A360B: g_array_sized_new (garray.c:193)
==5512==    by 0x48F2A39: gst_value_init_list_or_array (gstvalue.c:284)
==5512==    by 0x496D195: g_value_init (gvalue.c:175)
==5512==    by 0x682E453: ??? (in /usr/lib/gstreamer-1.0/libgstwaylandsink.so)


==5512== 25 bytes in 5 blocks are definitely lost in loss record 1,627 of 2,708
==5512==    at 0x4845750: malloc (vg_replace_malloc.c:296)
==5512==    by 0x49C6EC1: g_malloc (gmem.c:97)
==5512==    by 0x49D786D: g_strdup (gstrfuncs.c:356)
==5512==    by 0x496FC0F: g_value_set_string (gvaluetypes.c:1038)
==5512==    by 0x682E4EF: ??? (in /usr/lib/gstreamer-1.0/libgstwaylandsink.so)


==5512== 40 bytes in 1 blocks are definitely lost in loss record 1,880 of 2,708
==5512==    at 0x4847E64: calloc (vg_replace_malloc.c:623)
==5512==    by 0x67C83CB: ??? (in /usr/lib/libwayland-client.so.0.3.0)
==5512==    by 0x67C8763: wl_proxy_marshal_array_constructor_versioned (in /usr/lib/libwayland-client.so.0.3.0)
==5512==    by 0x67C88E7: wl_proxy_marshal_constructor_versioned (in /usr/lib/libwayland-client.so.0.3.0)
==5512==    by 0x6833FA7: ??? (in /usr/lib/gstreamer-1.0/libgstwaylandsink.so)
Comment 1 Hyunil Park 2016-06-29 02:24:44 UTC
Created attachment 330513 [details] [review]
patch file

After modifying code such as attached patch file, all memory leak is removed.
I checked valgrind tool.
thank you.
Comment 2 Tim-Philipp Müller 2016-06-29 07:23:10 UTC
*** Bug 768157 has been marked as a duplicate of this bug. ***
Comment 3 Nicolas Dufresne (ndufresne) 2016-09-26 14:14:40 UTC
Oops, fixed it without noticing, sorry.

commit 31d0a2c1eaff8e4824b47bbaa343297563712576
Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Date:   Fri Sep 23 15:49:21 2016 -0400

    waylandsink: Don't leak GValues in getcaps

commit ba71a392a653f0dc1d5a1cd41e6a57e701a7c200
Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Date:   Wed Sep 21 15:07:50 2016 -0400

    waylandsink: Destroy viewporter when done