[gst-devel] large memleaks

Jan Schmidt thaytan at noraisin.net
Wed Jun 13 16:25:14 CEST 2007


SP GLE wrote:
> Hi,
> I'm running my application under valgrind and i have large memleaks.

static_caps initialisations and memory plugin allocated during plugin
loading are not general considered leaks - they're just not cleaned up
on process exit because there's no point. They make noise in the
valgrind log, but they're not otherwise harmful (usually).

You really want to watch out for 'definitely lost' data blocks that are
accumulating during the running of the pipeline rather than things that
are initialised once and then reused.

In general, I don't consider any of the leaks you've posted to be
worrisome except perhaps the ffmpeg one. I'd need to look at the ffmpeg
code to investigate that though - it could again just be a one-time
initialisation that just doesn't get freed up because process exit will
do it anyway.

J.

> 
> Summary ::
> I have a lot of memory not freed with 'plugin_init()' in backtrace, 
> even with use of gst_deinit(),
> i looked at sources but found no method to unload previously loaded 
> plugins.
> 
> I also have large memleaks inside decodebin with typefind and caps 
> manipulation (which is may be the most suspicious memleak as caps often
> appear in backtraces as memleak) (please see below).
> 
> Questions ::
> - What can i do to keep only backtrace with real memory leaks ?
> - Is there a method to free/unload plugins, in order to easyly
> 	track memory leaks ?
> 
> My valgrind cmd is the following :
> 
> {
> export G_SLICE=always-malloc
> export G_DEBUG=gc-friendly
> export GLIBCPP_FORCE_NEW=1
> export GLIBCXX_FORCE_NEW=1
> 
> DP="/path/to/sources/"
> SUPP="--suppressions=/usr/lib/valgrind/glibc-2.3.supp 
> --suppressions=${DP}gstreamer/common/gst.supp 
> --suppressions=${DP}gst-plugins-base/common/gst.supp
> --suppressions=${DP}gst-plugins-good/common/gst.supp 
> --suppressions=${DP}gst-plugins-bad/common/gst.supp 
> --suppressions=${DP}gst-plugins-ugly/common/gst.supp 
> --suppressions=${DP}gst-ffmpeg/common/gst.supp"
> 
> OPTS="-v --trace-children=yes --track-fds=yes --time-stamp=yes 
> --tool=memcheck --leak-check=full --leak-resolution=high 
> --freelist-vol=10000000 --show-reachable=yes --num-callers=40 ${SUPP}"
> 
> valgrind $OPTS myapp
> }
> 
> Regards.
> 
> Backtraces ::
> 
> For ex., with a ffenc_h263p :
> 
> The finalize call is properly done on the element 
> 	...
> 0:02:26.480225000 18525 0x8068598 DEBUG        GST_PARENTAGE 
> gstelement.c:2859:gst_element_set_bus_func:<ffenc_h263p0> setting bus
> to (nil)
> 0:02:26.480572000 18525 0x8068598 DEBUG              default 
> gstelement.c:428:gst_element_set_clock:<ffenc_h263p0> setting clock
> (nil)
> 0:02:26.480639000 18525 0x8068598 LOG        GST_REFCOUNTING 
> gstobject.c:325:gst_object_ref:<ffenc_h263p0> 0x8224248 ref 1->2
> 0:02:26.480672000 18525 0x8068598 LOG        GST_REFCOUNTING 
> gstobject.c:870:gst_object_unparent:<ffenc_h263p0> unparent
> 0:02:26.480704000 18525 0x8068598 LOG        GST_REFCOUNTING 
> gstobject.c:352:gst_object_unref:<ffenc_h263p0> 0x8224248 unref 2->1
> 0:02:26.480741000 18525 0x8068598 LOG        GST_REFCOUNTING 
> gstobject.c:352:gst_object_unref:<ffenc_h263p0> 0x8224248 unref 1->0
> 0:02:26.480774000 18525 0x8068598 INFO       GST_REFCOUNTING 
> gstelement.c:2654:gst_element_dispose:<ffenc_h263p0> dispose
> 0:02:26.480806000 18525 0x8068598 DEBUG              default 
> gstelement.c:2659:gst_element_dispose:<ffenc_h263p0> removing 2 pads
> 0:02:26.480839000 18525 0x8068598 INFO      GST_ELEMENT_PADS 
> gstelement.c:746:gst_element_remove_pad:<ffenc_h263p0> removing pad
> 'src'
> 0:02:26.480880000 18525 0x8068598 LOG        GST_REFCOUNTING 
> gstobject.c:870:gst_object_unparent:<ffenc_h263p0:src> unparent
> 0:02:26.481335000 18525 0x8068598 INFO      GST_ELEMENT_PADS 
> gstelement.c:746:gst_element_remove_pad:<ffenc_h263p0> removing pad
> 'sink'
> 0:02:26.481373000 18525 0x8068598 LOG        GST_REFCOUNTING 
> gstobject.c:870:gst_object_unparent:<ffenc_h263p0:sink> unparent
> 0:02:26.481883000 18525 0x8068598 INFO       GST_REFCOUNTING 
> gstelement.c:2677:gst_element_dispose:<ffenc_h263p0> parent class
> dispose
> 0:02:26.481961000 18525 0x8068598 LOG        GST_REFCOUNTING 
> gstobject.c:438:gst_object_dispose:<ffenc_h263p0> dispose
> 0:02:26.482031000 18525 0x8068598 INFO       GST_REFCOUNTING 
> gstelement.c:2700:gst_element_finalize:<ffenc_h263p0> finalize
> 0:02:26.482067000 18525 0x8068598 INFO       GST_REFCOUNTING 
> gstelement.c:2711:gst_element_finalize:<ffenc_h263p0> finalize parent
> 0:02:26.482129000 18525 0x8068598 LOG        GST_REFCOUNTING 
> gstobject.c:470:gst_object_finalize:<ffenc_h263p0> finalize
> 
> but some memory is still reachable :
> 
> 32,776 bytes in 1 blocks are still reachable in loss record 10,644 of 
> 10,646
>     at 0x4005CBA: memalign (in 
> /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
>     by 0x4005D5F: posix_memalign (in 
> /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
>     by 0x559BDEA: av_malloc (mem.c:64)
>     by 0x54DCBD5: av_mallocz (utils.c:64)
>     by 0x5479371: init_mv_penalty_and_fcode (h263.c:1783)
>     by 0x5479C25: h263_encode_init (h263.c:2028)
>     by 0x559F8BE: MPV_encode_init (mpegvideo.c:1329)
>     by 0x54DD767: avcodec_open (utils.c:858)
>     by 0x53B76DC: gst_ffmpeg_avcodec_open (gstffmpeg.c:49)
>     by 0x53BDF98: gst_ffmpegenc_getcaps (gstffmpegenc.c:326)
>     by 0x406279A: gst_pad_get_caps_unlocked (gstpad.c:1967)
>     by 0x40619EB: gst_pad_link_check_compatible_unlocked 
> (gstpad.c:1638)
>     by 0x4062071: gst_pad_link_prepare (gstpad.c:1783)
>     by 0x40622E8: gst_pad_link (gstpad.c:1858)
>     by 0x407D61D: pad_link_maybe_ghosting (gstutils.c:1311)
>     by 0x407E056: gst_element_link_pads (gstutils.c:1455)
>     by 0x407E622: gst_element_link_pads_filtered (gstutils.c:1643)
>     by 0x407E667: gst_element_link (gstutils.c:1666)
>     by 0x407E6EB: gst_element_link_many (gstutils.c:1692)
> 
> I could suppose it is a memleak inside avcodec but I also have large 
> chunks of memory allocated during plugin_init() :
> 
>  13,728 bytes in 52 blocks are still reachable in loss record 10,639 of
> 
> 10,646
>     at 0x4005B02: calloc (in 
> /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
>     by 0x43716294: g_malloc0 (in /usr/lib/libglib-2.0.so.0.1200.1)
>     by 0x4379BDAE: (within /usr/lib/libgobject-2.0.so.0.1200.1)
>     by 0x4379D5A0: g_type_class_ref (in 
> /usr/lib/libgobject-2.0.so.0.1200.1)
>     by 0x4052F65: gst_element_register (gstelementfactory.c:273)
>     by 0x53BFC6A: gst_ffmpegenc_register (gstffmpegenc.c:984)
>     by 0x53B79A0: plugin_init (gstffmpeg.c:125)
>     by 0x406A90E: gst_plugin_register_func (gstplugin.c:258)
>     by 0x406AE46: gst_plugin_load_file (gstplugin.c:454)
>     by 0x406B5A2: gst_plugin_load_by_name (gstplugin.c:878)
>     by 0x406B9AF: gst_plugin_feature_load (gstpluginfeature.c:113)
>     by 0x40532B0: gst_element_factory_create (gstelementfactory.c:366)
>     by 0x40535AF: gst_element_factory_make (gstelementfactory.c:454)
> 
> 
> I have a lot of memory not freed with 'plugin_init()' in backtrace, 
> even with use of gst_deinit(),
> i looked at sources but found no method to unload previously loaded 
> plugins.
> 
> I also have large memleaks inside decodebin with typefind and caps 
> manipulation (which is may be the most suspicious
> memleak):
> 
>  55,280 (2,796 direct, 52,484 indirect) bytes in 233 blocks are 
> definitely lost in loss record 9,799 of 10,646
>     at 0x40046F2: malloc (in 
> /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
>     by 0x4371620C: g_malloc (in /usr/lib/libglib-2.0.so.0.1200.1)
>     by 0x43725551: g_slice_alloc (in /usr/lib/libglib-2.0.so.0.1200.1)
>     by 0x436F1D1A: g_ptr_array_sized_new (in 
> /usr/lib/libglib-2.0.so.0.1200.1)
>     by 0x436F1CF1: g_ptr_array_new (in 
> /usr/lib/libglib-2.0.so.0.1200.1)
>     by 0x40480E8: gst_static_caps_get (gstcaps.c:460)
>     by 0x7F690B7: find_compatibles (gstdecodebin.c:525)
>     by 0x7F69929: close_pad_link (gstdecodebin.c:756)
>     by 0x7F6B5F6: type_found (gstdecodebin.c:1559)
>     by 0x408CFB3: gst_marshal_VOID__UINT_BOXED (gstmarshal.c:507)
>     by 0x437845D4: g_closure_invoke (in 
> /usr/lib/libgobject-2.0.so.0.1200.1)
>     by 0x43796837: (within /usr/lib/libgobject-2.0.so.0.1200.1)
>     by 0x437958BB: g_signal_emit_valist (in 
> /usr/lib/libgobject-2.0.so.0.1200.1)
>     by 0x43795B55: g_signal_emit (in 
> /usr/lib/libgobject-2.0.so.0.1200.1)
>     by 0x5B6D236: gst_type_find_element_activate 
> (gsttypefindelement.c:743)
>     by 0x405F5ED: gst_pad_set_active (gstpad.c:648)
>     by 0x40519C9: activate_pads (gstelement.c:2446)
>     by 0x405C4A8: gst_iterator_fold (gstiterator.c:503)
>     by 0x4051A7B: iterator_activate_fold_with_resync 
> (gstelement.c:2478)
>     by 0x4051B7F: gst_element_pads_activate (gstelement.c:2521)
>     by 0x4051D27: gst_element_change_state_func (gstelement.c:2586)
>     by 0x5B6D2D4: gst_type_find_element_change_state 
> (gsttypefindelement.c:770)
>     by 0x405199C: gst_element_change_state (gstelement.c:2362)
>     by 0x40514A9: gst_element_set_state_func (gstelement.c:2312)
>     by 0x405134C: gst_element_set_state (gstelement.c:2218)
>     by 0x4042035: gst_bin_element_set_state (gstbin.c:1955)
>     by 0x4042606: gst_bin_change_state_func (gstbin.c:2128)
>     by 0x7F6BD2F: gst_decode_bin_change_state (gstdecodebin.c:1694)
>     by 0x405199C: gst_element_change_state (gstelement.c:2362)
>     by 0x40514A9: gst_element_set_state_func (gstelement.c:2312)
>     by 0x405134C: gst_element_set_state (gstelement.c:2218)
>     by 0x4042035: gst_bin_element_set_state (gstbin.c:1955)
>     by 0x4042606: gst_bin_change_state_func (gstbin.c:2128)
>     by 0x406857F: gst_pipeline_change_state (gstpipeline.c:503)
>     by 0x405199C: gst_element_change_state (gstelement.c:2362)
>     by 0x4050F1E: gst_element_continue_state (gstelement.c:2077)
>     by 0x40517D9: gst_element_change_state (gstelement.c:2406)
>     by 0x40514A9: gst_element_set_state_func (gstelement.c:2312)
>     by 0x405134C: gst_element_set_state (gstelement.c:2218)
> 
> 
> 18,432 bytes in 151 blocks are indirectly lost in loss record 9,798 of 
> 10,646
>     at 0x4005BEC: realloc (in 
> /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
>     by 0x4371633C: g_realloc (in /usr/lib/libglib-2.0.so.0.1200.1)
>     by 0x436F1C9A: (within /usr/lib/libglib-2.0.so.0.1200.1)
>     by 0x436F15CB: g_array_append_vals (in 
> /usr/lib/libglib-2.0.so.0.1200.1)
>     by 0x4071721: gst_structure_set_field (gststructure.c:593)
>     by 0x407341C: gst_structure_from_string (gststructure.c:1848)
>     by 0x4049F23: gst_caps_from_string_inplace (gstcaps.c:1821)
>     by 0x4048107: gst_static_caps_get (gstcaps.c:467)
>     by 0x7F690B7: find_compatibles (gstdecodebin.c:525)
>     by 0x7F69929: close_pad_link (gstdecodebin.c:756)
>     by 0x7F6B5F6: type_found (gstdecodebin.c:1559)
>     by 0x408CFB3: gst_marshal_VOID__UINT_BOXED (gstmarshal.c:507)
>     by 0x437845D4: g_closure_invoke (in 
> /usr/lib/libgobject-2.0.so.0.1200.1)
>     by 0x43796837: (within /usr/lib/libgobject-2.0.so.0.1200.1)
>     by 0x437958BB: g_signal_emit_valist (in 
> /usr/lib/libgobject-2.0.so.0.1200.1)
>     by 0x43795B55: g_signal_emit (in 
> /usr/lib/libgobject-2.0.so.0.1200.1)
>     by 0x5B6D236: gst_type_find_element_activate 
> (gsttypefindelement.c:743)
>     by 0x405F5ED: gst_pad_set_active (gstpad.c:648)
>     by 0x40519C9: activate_pads (gstelement.c:2446)
>     by 0x405C4A8: gst_iterator_fold (gstiterator.c:503)
>     by 0x4051A7B: iterator_activate_fold_with_resync 
> (gstelement.c:2478)
>     by 0x4051B7F: gst_element_pads_activate (gstelement.c:2521)
>     by 0x4051D27: gst_element_change_state_func (gstelement.c:2586)
>     by 0x5B6D2D4: gst_type_find_element_change_state 
> (gsttypefindelement.c:770)
>     by 0x405199C: gst_element_change_state (gstelement.c:2362)
>     by 0x40514A9: gst_element_set_state_func (gstelement.c:2312)
>     by 0x405134C: gst_element_set_state (gstelement.c:2218)
>     by 0x4042035: gst_bin_element_set_state (gstbin.c:1955)
>     by 0x4042606: gst_bin_change_state_func (gstbin.c:2128)
>     by 0x7F6BD2F: gst_decode_bin_change_state (gstdecodebin.c:1694)
>     by 0x405199C: gst_element_change_state (gstelement.c:2362)
>     by 0x40514A9: gst_element_set_state_func (gstelement.c:2312)
>     by 0x405134C: gst_element_set_state (gstelement.c:2218)
>     by 0x4042035: gst_bin_element_set_state (gstbin.c:1955)
>     by 0x4042606: gst_bin_change_state_func (gstbin.c:2128)
>     by 0x406857F: gst_pipeline_change_state (gstpipeline.c:503)
>     by 0x405199C: gst_element_change_state (gstelement.c:2362)
>     by 0x4050F1E: gst_element_continue_state (gstelement.c:2077)
>     by 0x40517D9: gst_element_change_state (gstelement.c:2406)
>     by 0x40514A9: gst_element_set_state_func (gstelement.c:2312)
> 
> 
> 
>  14,848 bytes in 232 blocks are indirectly lost in loss record 9,797 of
> 
> 10,646
>     at 0x40046F2: malloc (in 
> /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
>     by 0x4005B80: realloc (in 
> /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
>     by 0x4371633C: g_realloc (in /usr/lib/libglib-2.0.so.0.1200.1)
>     by 0x436F1E36: (within /usr/lib/libglib-2.0.so.0.1200.1)
>     by 0x436F229E: g_ptr_array_add (in 
> /usr/lib/libglib-2.0.so.0.1200.1)
>     by 0x40486BF: gst_caps_append_structure (gstcaps.c:696)
>     by 0x4049F38: gst_caps_from_string_inplace (gstcaps.c:1825)
>     by 0x4048107: gst_static_caps_get (gstcaps.c:467)
>     by 0x7F690B7: find_compatibles (gstdecodebin.c:525)
>     by 0x7F69929: close_pad_link (gstdecodebin.c:756)
>     by 0x7F6B5F6: type_found (gstdecodebin.c:1559)
>     by 0x408CFB3: gst_marshal_VOID__UINT_BOXED (gstmarshal.c:507)
>     by 0x437845D4: g_closure_invoke (in 
> /usr/lib/libgobject-2.0.so.0.1200.1)
>     by 0x43796837: (within /usr/lib/libgobject-2.0.so.0.1200.1)
>     by 0x437958BB: g_signal_emit_valist (in 
> /usr/lib/libgobject-2.0.so.0.1200.1)
>     by 0x43795B55: g_signal_emit (in 
> /usr/lib/libgobject-2.0.so.0.1200.1)
>     by 0x5B6D236: gst_type_find_element_activate 
> (gsttypefindelement.c:743)
>     by 0x405F5ED: gst_pad_set_active (gstpad.c:648)
>     by 0x40519C9: activate_pads (gstelement.c:2446)
>     by 0x405C4A8: gst_iterator_fold (gstiterator.c:503)
>     by 0x4051A7B: iterator_activate_fold_with_resync 
> (gstelement.c:2478)
>     by 0x4051B7F: gst_element_pads_activate (gstelement.c:2521)
>     by 0x4051D27: gst_element_change_state_func (gstelement.c:2586)
>     by 0x5B6D2D4: gst_type_find_element_change_state 
> (gsttypefindelement.c:770)
>     by 0x405199C: gst_element_change_state (gstelement.c:2362)
>     by 0x40514A9: gst_element_set_state_func (gstelement.c:2312)
>     by 0x405134C: gst_element_set_state (gstelement.c:2218)
>     by 0x4042035: gst_bin_element_set_state (gstbin.c:1955)
>     by 0x4042606: gst_bin_change_state_func (gstbin.c:2128)
>     by 0x7F6BD2F: gst_decode_bin_change_state (gstdecodebin.c:1694)
>     by 0x405199C: gst_element_change_state (gstelement.c:2362)
>     by 0x40514A9: gst_element_set_state_func (gstelement.c:2312)
>     by 0x405134C: gst_element_set_state (gstelement.c:2218)
>     by 0x4042035: gst_bin_element_set_state (gstbin.c:1955)
>     by 0x4042606: gst_bin_change_state_func (gstbin.c:2128)
>     by 0x406857F: gst_pipeline_change_state (gstpipeline.c:503)
>     by 0x405199C: gst_element_change_state (gstelement.c:2362)
>     by 0x4050F1E: gst_element_continue_state (gstelement.c:2077)
>     by 0x40517D9: gst_element_change_state (gstelement.c:2406)
>     by 0x40514A9: gst_element_set_state_func (gstelement.c:2312)
> 
>  4,640 bytes in 232 blocks are indirectly lost in loss record 9,796 of 
> 10,646
>     at 0x40046F2: malloc (in 
> /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
>     by 0x4371620C: g_malloc (in /usr/lib/libglib-2.0.so.0.1200.1)
>     by 0x43725551: g_slice_alloc (in /usr/lib/libglib-2.0.so.0.1200.1)
>     by 0x436F1478: g_array_sized_new (in 
> /usr/lib/libglib-2.0.so.0.1200.1)
>     by 0x4070AEF: gst_structure_id_empty_new_with_size 
> (gststructure.c:118)
>     by 0x4070B72: gst_structure_empty_new (gststructure.c:153)
>     by 0x4073377: gst_structure_from_string (gststructure.c:1834)
>     by 0x4049F23: gst_caps_from_string_inplace (gstcaps.c:1821)
>     by 0x4048107: gst_static_caps_get (gstcaps.c:467)
>     by 0x7F690B7: find_compatibles (gstdecodebin.c:525)
>     by 0x7F69929: close_pad_link (gstdecodebin.c:756)
>     by 0x7F6B5F6: type_found (gstdecodebin.c:1559)
>     by 0x408CFB3: gst_marshal_VOID__UINT_BOXED (gstmarshal.c:507)
>     by 0x437845D4: g_closure_invoke (in 
> /usr/lib/libgobject-2.0.so.0.1200.1)
>     by 0x43796837: (within /usr/lib/libgobject-2.0.so.0.1200.1)
>     by 0x437958BB: g_signal_emit_valist (in 
> /usr/lib/libgobject-2.0.so.0.1200.1)
>     by 0x43795B55: g_signal_emit (in 
> /usr/lib/libgobject-2.0.so.0.1200.1)
>     by 0x5B6D236: gst_type_find_element_activate 
> (gsttypefindelement.c:743)
>     by 0x405F5ED: gst_pad_set_active (gstpad.c:648)
>     by 0x40519C9: activate_pads (gstelement.c:2446)
>     by 0x405C4A8: gst_iterator_fold (gstiterator.c:503)
>     by 0x4051A7B: iterator_activate_fold_with_resync 
> (gstelement.c:2478)
>     by 0x4051B7F: gst_element_pads_activate (gstelement.c:2521)
>     by 0x4051D27: gst_element_change_state_func (gstelement.c:2586)
>     by 0x5B6D2D4: gst_type_find_element_change_state 
> (gsttypefindelement.c:770)
>     by 0x405199C: gst_element_change_state (gstelement.c:2362)
>     by 0x40514A9: gst_element_set_state_func (gstelement.c:2312)
>     by 0x405134C: gst_element_set_state (gstelement.c:2218)
>     by 0x4042035: gst_bin_element_set_state (gstbin.c:1955)
>     by 0x4042606: gst_bin_change_state_func (gstbin.c:2128)
>     by 0x7F6BD2F: gst_decode_bin_change_state (gstdecodebin.c:1694)
>     by 0x405199C: gst_element_change_state (gstelement.c:2362)
>     by 0x40514A9: gst_element_set_state_func (gstelement.c:2312)
>     by 0x405134C: gst_element_set_state (gstelement.c:2218)
>     by 0x4042035: gst_bin_element_set_state (gstbin.c:1955)
>     by 0x4042606: gst_bin_change_state_func (gstbin.c:2128)
>     by 0x406857F: gst_pipeline_change_state (gstpipeline.c:503)
>     by 0x405199C: gst_element_change_state (gstelement.c:2362)
>     by 0x4050F1E: gst_element_continue_state (gstelement.c:2077)
>     by 0x40517D9: gst_element_change_state (gstelement.c:2406)
> 
> 
> 
> 
>       _____________________________________________________________________________ 
> Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
> 





More information about the gstreamer-devel mailing list