tracking memory leaks - gstreamer...qa friendly only track leaks ... gst_fake_sink_class_intern_init...
TRANSCRIPT
![Page 1: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/1.jpg)
Open First
Tracking memory leaksGStreamer Conference 2016 - Berlin
![Page 2: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/2.jpg)
Dead to all leaks
● Increase memory consumption● OOM● Crashes
GStreamer Conference 2
![Page 3: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/3.jpg)
Existing tools
![Page 4: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/4.jpg)
Valgrind: pros
● Most common tool● Detect all type of leaks● Full stack trace● gst-validate support
GStreamer Conference 4
![Page 5: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/5.jpg)
Valgrind: cons
● Low level● Very slow● CPU● Tricky to use on some systems● False positives● “Noise”● System/distro specific supp files
GStreamer Conference 5
![Page 6: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/6.jpg)
Refcounting logs
● GST_DEBUG=GST_REFCOUNTING:5
GStreamer Conference 6
![Page 7: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/7.jpg)
GST_TRACE
● Internal debugging tool (until 1.10)● Track GstObject and GstMiniObject● Fase positives● Not great for QA tools
GStreamer Conference 7
![Page 8: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/8.jpg)
GST_TRACE
GST_TRACE=all gst-launch-1.0 fakesrc num-buffers=1 ! fakesink
● GstMiniObject : 4● GstCaps : (2) 0x56270cc344a0 ("ANY")● GstCaps : (2) 0x56270cc34450 ("ANY")● GstCaps : (1) 0x56270cad9050 ("EMPTY")● GstCaps : (1) 0x56270cad9000 ("ANY")● GstObject : 4● GstTaskPool : (1) 0x56270ccdb430● GstPadTemplate : (1) 0x56270cae1410● GstPadTemplate : (1) 0x56270cae12f0● GstAllocatorSysmem : (3) 0x56270cae3040●
GStreamer Conference 8
![Page 9: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/9.jpg)
gst-leaks
![Page 10: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/10.jpg)
“Leaked” flag
● GST_OBJECT_FLAG_MAY_BE_LEAKED● GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED
GStreamer Conference 10
![Page 11: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/11.jpg)
GstTracer
● Tracing module loaded at run time● Monitoring hooks● Formatted output
GStreamer Conference 11
![Page 12: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/12.jpg)
Hooks
● Gst(Mini)Object created● Gst(Mini)Object destroyed
GStreamer Conference 12
![Page 13: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/13.jpg)
gstleaks
● Implemented as a GstTracer● Track GstObject and GstMiniObject● Raise a GLib warning if leaks are detected● GST_DEBUG="GST_TRACER:7" GST_TRACERS="leaks" gst-launch-1.0
videotestsrc num-buffers=10 ! Fakesink
GStreamer Conference 13
![Page 14: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/14.jpg)
Filtering support
● GST_DEBUG="GST_TRACER:7" GST_TRACERS="leaks(GstTaskPool,GstCaps)" gst-launch-1.0 videotestsrc num-buffers=10 ! Fakesink
● object-alive, type-name=(string)GstTaskPool, address=(gpointer)0xf3ed90, description=(string)<taskpool1>, ref-count=(uint)1, trace=(string);
● object-alive, type-name=(string)GstCaps, address=(gpointer)0x1899de0, description=(string)ANY, ref-count=(uint)2, trace=(string);
GStreamer Conference 14
![Page 15: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/15.jpg)
Gstleaks: pro
● Much lighter/faster than valgrind● Integrated in core (1.10)● QA friendly● Only track leaks in gst code● No false positives● Helped fixing loads of leaks
GStreamer Conference 15
![Page 16: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/16.jpg)
Stack trace
● Libunwind (optional)● GST_LEAKS_TRACER_STACK_TRACE=1 GST_DEBUG="GST_TRACER:7"
GST_TRACERS="leaks" gst-launch-1.0 videotestsrc num-buffers=10 ! Fakesink● object-alive, type-name=(string)GstCaps, address=(gpointer)0xc39cf0, description=(string)ANY, ref-
count=(uint)2, trace=(string)handle_object_created.part.0● gst_mini_object_init● gst_caps_new_empty● gst_caps_from_string● gst_static_caps_get● gst_static_pad_template_get● gst_element_class_add_static_pad_template● gst_fake_sink_class_intern_init● g_type_class_ref● g_object_newv● gst_element_factory_create● gst_element_factory_make● priv_gst_parse_yyparse● priv_gst_parse_launch● gst_parse_launch_full● gst_parse_launchv_full
GStreamer Conference 16
![Page 17: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/17.jpg)
Signal support
● Borrowed from gobject-list● GST_LEAKS_TRACER_SIG● SIGUSR1: log alive objects● SIGUSR2: log objects created/destroyed
since the previous checkpoint
GStreamer Conference 17
![Page 18: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/18.jpg)
Debugging leaks
![Page 19: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/19.jpg)
● gst_deinit()● Find the “top” leak● Only Gst(Mini)Object are tracked● Filter when using
GST_LEAKS_TRACER_STACK_TRACE
GStreamer Conference 19
![Page 20: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/20.jpg)
gdb
● Track refcount changes– b gst_mini_object_ref if (mini_object == 0xdeadbeef)
– b gst_mini_object_unref if (mini_object == 0xdeadbeef)
– commands 1 2
– bt
– cont
– end
● Ignore GObject signal and property code paths
GStreamer Conference 20
![Page 21: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/21.jpg)
Refcount transfers
● (transfer full) API● Tricky to debug
(GST_PAD_PROBE_HANDLED)
GStreamer Conference 21
![Page 22: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/22.jpg)
Future improvements
● Better stack trace (file + line)● GUI tracking alive objects? gst-debugger?● Suggestions?
GStreamer Conference 22
![Page 23: Tracking memory leaks - GStreamer...QA friendly Only track leaks ... gst_fake_sink_class_intern_init ... PowerPoint Presentation Author: Mark Filion Created Date: 10/10/2016 10:14:52](https://reader033.vdocuments.site/reader033/viewer/2022050211/5f5df79cf8a73e669969a7b2/html5/thumbnails/23.jpg)
Thank you!