memory leak when switching state or camera of rtsp pipeline
Describe your issue
memory leak when switching state or camera with rtsp pipeline
Setup
- Operating System: Ubuntu 18.04 Desktop
- Device: Computer with or without touchscreen
- GStreamer Version: 1.14.5. The problem is still there with 1.18
Steps to reproduce the bug
- switch state of pipeline from Playing to NULL or vice versa
- switch camera by rebuilding rtsp pipeline
- Tried the change in #106 and no luck
How reproducible is the bug?
the following output is obtained from valgrind with debug vaapi build
==26825== 57,506 (144 direct, 57,362 indirect) bytes in 2 blocks are definitely lost in loss record 16,617 of 16,634
==26825== at 0x4C31B0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26825== by 0xBCBFBD8: g_malloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.5600.4)
==26825== by 0xBCD7A85: g_slice_alloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.5600.4)
==26825== by 0x6C1A61B0: gst_vaapi_mini_object_new (gstvaapiminiobject.c:73)
==26825== by 0x6C1A6338: gst_vaapi_object_new (gstvaapiobject.c:90)
==26825== by 0x6C1A7DC9: gst_vaapi_surface_new_full (gstvaapisurface.c:378)
==26825== by 0x6C174A55: extract_allowed_surface_formats (gstvaapipluginbase.c:1289)
==26825== by 0x6C174A55: ensure_allowed_raw_caps.part.1 (gstvaapipluginbase.c:1342)
==26825== by 0x6C1762DC: ensure_allowed_raw_caps (gstvaapipluginbase.c:1396)
==26825== by 0x6C1762DC: gst_vaapi_plugin_base_get_allowed_srcpad_raw_caps (gstvaapipluginbase.c:1393)
==26825== by 0x6C172E2C: gst_vaapidecode_ensure_allowed_srcpad_caps (gstvaapidecode.c:241)
==26825== by 0x6C172E2C: gst_vaapidecode_get_allowed_srcpad_caps (gstvaapidecode.c:265)
==26825== by 0x6C172E2C: gst_vaapidecode_update_src_caps (gstvaapidecode.c:293)
==26825== by 0x6C172E2C: gst_vaapidecode_negotiate (gstvaapidecode.c:489)
==26825== by 0x6C172E2C: gst_vaapidecode_push_decoded_frame (gstvaapidecode.c:547)
==26825== by 0x6C172E2C: gst_vaapidecode_push_all_decoded_frames (gstvaapidecode.c:694)
==26825== by 0x16877EA0: gst_video_decoder_decode_frame (gstvideodecoder.c:3416)
==26825== by 0x1688048E: gst_video_decoder_have_frame (gstvideodecoder.c:3348)
==26825== by 0x6C172299: gst_vaapidecode_parse_frame (gstvaapidecode.c:1164)
==26825== by 0x6C172299: gst_vaapidecode_parse (gstvaapidecode.c:1195)
==26825==
==26825== 65,536 bytes in 2 blocks are possibly lost in loss record 16,621 of 16,634
==26825== at 0x4C31B0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26825== by 0x30B4E8BC: drm_intel_setup_reloc_list (intel_bufmgr_gem.c:618)
==26825== by 0x30B5613A: do_bo_emit_reloc (intel_bufmgr_gem.c:1993)
==26825== by 0x30B5669D: drm_intel_gem_bo_emit_reloc (intel_bufmgr_gem.c:2102)
==26825== by 0x30B4A517: drm_intel_bo_emit_reloc (intel_bufmgr.c:203)
==26825== by 0x6D36851C: gen7_pp_set_surface2_state.isra.23.constprop.34 (i965_post_processing.c:1947)
==26825== by 0x6D3689E2: gen7_pp_set_media_rw_message_surface (i965_post_processing.c:2209)
==26825== by 0x6D368D55: gen7_pp_plx_avs_initialize (i965_post_processing.c:3069)
==26825== by 0x6D365F17: gen6_pp_initialize (i965_post_processing.c:4379)
==26825== by 0x6D365F17: gen6_post_processing (i965_post_processing.c:4707)
==26825== by 0x6D3650E9: i965_post_processing_internal (i965_post_processing.c:4741)
==26825== by 0x6D3650E9: i965_image_pl2_processing (i965_post_processing.c:5235)
==26825== by 0x6D36C800: i965_image_processing (i965_post_processing.c:5542)
==26825== by 0x6D346F0C: i965_hw_getimage (i965_drv_video.c:5253)
==26825== by 0x6D346F0C: i965_GetImage (i965_drv_video.c:5298)
==26825==
==26825== 65,536 bytes in 2 blocks are possibly lost in loss record 16,622 of 16,634
==26825== at 0x4C31B0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26825== by 0x30B4E8BC: drm_intel_setup_reloc_list (intel_bufmgr_gem.c:618)
==26825== by 0x30B5613A: do_bo_emit_reloc (intel_bufmgr_gem.c:1993)
==26825== by 0x30B5669D: drm_intel_gem_bo_emit_reloc (intel_bufmgr_gem.c:2102)
==26825== by 0x30B4A517: drm_intel_bo_emit_reloc (intel_bufmgr.c:203)
==26825== by 0x6D369292: gen7_pp_plx_avs_initialize (i965_post_processing.c:3189)
==26825== by 0x6D365F17: gen6_pp_initialize (i965_post_processing.c:4379)
==26825== by 0x6D365F17: gen6_post_processing (i965_post_processing.c:4707)
==26825== by 0x6D3650E9: i965_post_processing_internal (i965_post_processing.c:4741)
==26825== by 0x6D3650E9: i965_image_pl2_processing (i965_post_processing.c:5235)
==26825== by 0x6D36C800: i965_image_processing (i965_post_processing.c:5542)
==26825== by 0x6D346F0C: i965_hw_getimage (i965_drv_video.c:5253)
==26825== by 0x6D346F0C: i965_GetImage (i965_drv_video.c:5298)
==26825== by 0x6C1A88CF: gst_vaapi_surface_get_image (gstvaapisurface.c:697)
==26825== by 0x6C184D68: ensure_image_is_current (gstvaapivideomemory.c:156)
==26825== by 0x6C184D68: map_vaapi_memory (gstvaapivideomemory.c:247)
==26825== by 0x6C184D68: gst_video_meta_map_vaapi_memory (gstvaapivideomemory.c:326)
==26825==
==26825== 65,536 bytes in 2 blocks are possibly lost in loss record 16,623 of 16,634
==26825== at 0x4C31B0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26825== by 0x30B4E8BC: drm_intel_setup_reloc_list (intel_bufmgr_gem.c:618)
==26825== by 0x30B5613A: do_bo_emit_reloc (intel_bufmgr_gem.c:1993)
==26825== by 0x30B5669D: drm_intel_gem_bo_emit_reloc (intel_bufmgr_gem.c:2102)
==26825== by 0x30B4A517: drm_intel_bo_emit_reloc (intel_bufmgr.c:203)
==26825== by 0x6D366104: gen6_pp_interface_descriptor_table (i965_post_processing.c:4424)
==26825== by 0x6D366104: gen6_pp_states_setup (i965_post_processing.c:4467)
==26825== by 0x6D366104: gen6_post_processing (i965_post_processing.c:4716)
==26825== by 0x6D3650E9: i965_post_processing_internal (i965_post_processing.c:4741)
==26825== by 0x6D3650E9: i965_image_pl2_processing (i965_post_processing.c:5235)
==26825== by 0x6D36C800: i965_image_processing (i965_post_processing.c:5542)
==26825== by 0x6D346F0C: i965_hw_getimage (i965_drv_video.c:5253)
==26825== by 0x6D346F0C: i965_GetImage (i965_drv_video.c:5298)
==26825== by 0x6C1A88CF: gst_vaapi_surface_get_image (gstvaapisurface.c:697)
==26825== by 0x6C184D68: ensure_image_is_current (gstvaapivideomemory.c:156)
==26825== by 0x6C184D68: map_vaapi_memory (gstvaapivideomemory.c:247)
==26825== by 0x6C184D68: gst_video_meta_map_vaapi_memory (gstvaapivideomemory.c:326)
==26825== by 0x1686DB3E: gst_video_frame_map_id (video-frame.c:103)
==26825==
==26825== 262,144 bytes in 2 blocks are definitely lost in loss record 16,628 of 16,634
==26825== at 0x30B54F35: drm_intel_gem_bo_map (intel_bufmgr_gem.c:1485)
==26825== by 0x30B4A221: drm_intel_bo_map (intel_bufmgr.c:103)
==26825== by 0x6D36653B: gen6_pp_object_walker (i965_post_processing.c:4630)
==26825== by 0x6D36653B: gen6_pp_pipeline_setup (i965_post_processing.c:4689)
==26825== by 0x6D36653B: gen6_post_processing (i965_post_processing.c:4717)
==26825== by 0x6D3650E9: i965_post_processing_internal (i965_post_processing.c:4741)
==26825== by 0x6D3650E9: i965_image_pl2_processing (i965_post_processing.c:5235)
==26825== by 0x6D36C800: i965_image_processing (i965_post_processing.c:5542)
==26825== by 0x6D346F0C: i965_hw_getimage (i965_drv_video.c:5253)
==26825== by 0x6D346F0C: i965_GetImage (i965_drv_video.c:5298)
==26825== by 0x6C1A88CF: gst_vaapi_surface_get_image (gstvaapisurface.c:697)
==26825== by 0x6C184D68: ensure_image_is_current (gstvaapivideomemory.c:156)
==26825== by 0x6C184D68: map_vaapi_memory (gstvaapivideomemory.c:247)
==26825== by 0x6C184D68: gst_video_meta_map_vaapi_memory (gstvaapivideomemory.c:326)
==26825== by 0x1686DB3E: gst_video_frame_map_id (video-frame.c:103)
==26825== by 0x16871E28: gst_video_filter_transform (gstvideofilter.c:263)
==26825== by 0x1ED73400: default_generate_output (gstbasetransform.c:2132)
==26825== by 0x1ED72B83: gst_base_transform_chain (gstbasetransform.c:2285)
==26825==
==26825== 524,288 bytes in 1 blocks are definitely lost in loss record 16,629 of 16,634
==26825== at 0x30B54F35: drm_intel_gem_bo_map (intel_bufmgr_gem.c:1485)
==26825== by 0x30B4A221: drm_intel_bo_map (intel_bufmgr.c:103)
==26825== by 0x6D37F5F7: intel_batchbuffer_reset (intel_batchbuffer.c:62)
==26825== by 0x6D36668D: gen6_pp_object_walker (i965_post_processing.c:4672)
==26825== by 0x6D36668D: gen6_pp_pipeline_setup (i965_post_processing.c:4689)
==26825== by 0x6D36668D: gen6_post_processing (i965_post_processing.c:4717)
==26825== by 0x6D3653D1: i965_post_processing_internal (i965_post_processing.c:4741)
==26825== by 0x6D3653D1: i965_image_pl3_processing (i965_post_processing.c:5151)
==26825== by 0x6D36C830: i965_image_processing (i965_post_processing.c:5534)
==26825== by 0x6D34DFFF: i965_hw_putimage (i965_drv_video.c:5556)
==26825== by 0x6D34DFFF: i965_PutImage (i965_drv_video.c:5617)
==26825== by 0x6C1A89C8: gst_vaapi_surface_put_image (gstvaapisurface.c:741)
==26825== by 0x6C174973: extract_allowed_surface_formats (gstvaapipluginbase.c:1307)
==26825== by 0x6C174973: ensure_allowed_raw_caps.part.1 (gstvaapipluginbase.c:1342)
==26825== by 0x6C17628E: ensure_allowed_raw_caps (gstvaapipluginbase.c:1378)
==26825== by 0x6C17628E: gst_vaapi_plugin_base_get_allowed_sinkpad_raw_caps (gstvaapipluginbase.c:1375)
==26825== by 0x6C17A4C1: ensure_allowed_sinkpad_caps (gstvaapipostproc.c:1099)
==26825== by 0x6C17A4C1: gst_vaapipostproc_transform_caps_impl (gstvaapipostproc.c:1193)
==26825== by 0x6C17A4C1: gst_vaapipostproc_transform_caps (gstvaapipostproc.c:1216)
==26825== by 0x1ED7237D: gst_base_transform_transform_caps (gstbasetransform.c:465)
==26825==
==26825== 524,288 bytes in 1 blocks are definitely lost in loss record 16,630 of 16,634
==26825== at 0x30B54F35: drm_intel_gem_bo_map (intel_bufmgr_gem.c:1485)
==26825== by 0x30B4A221: drm_intel_bo_map (intel_bufmgr.c:103)
==26825== by 0x6D37F5F7: intel_batchbuffer_reset (intel_batchbuffer.c:62)
==26825== by 0x6D36668D: gen6_pp_object_walker (i965_post_processing.c:4672)
==26825== by 0x6D36668D: gen6_pp_pipeline_setup (i965_post_processing.c:4689)
==26825== by 0x6D36668D: gen6_post_processing (i965_post_processing.c:4717)
==26825== by 0x6D3650E9: i965_post_processing_internal (i965_post_processing.c:4741)
==26825== by 0x6D3650E9: i965_image_pl2_processing (i965_post_processing.c:5235)
==26825== by 0x6D36C800: i965_image_processing (i965_post_processing.c:5542)
==26825== by 0x6D34DFFF: i965_hw_putimage (i965_drv_video.c:5556)
==26825== by 0x6D34DFFF: i965_PutImage (i965_drv_video.c:5617)
==26825== by 0x6C1A89C8: gst_vaapi_surface_put_image (gstvaapisurface.c:741)
==26825== by 0x6C174973: extract_allowed_surface_formats (gstvaapipluginbase.c:1307)
==26825== by 0x6C174973: ensure_allowed_raw_caps.part.1 (gstvaapipluginbase.c:1342)
==26825== by 0x6C17628E: ensure_allowed_raw_caps (gstvaapipluginbase.c:1378)
==26825== by 0x6C17628E: gst_vaapi_plugin_base_get_allowed_sinkpad_raw_caps (gstvaapipluginbase.c:1375)
==26825== by 0x6C17A4C1: ensure_allowed_sinkpad_caps (gstvaapipostproc.c:1099)
==26825== by 0x6C17A4C1: gst_vaapipostproc_transform_caps_impl (gstvaapipostproc.c:1193)
==26825== by 0x6C17A4C1: gst_vaapipostproc_transform_caps (gstvaapipostproc.c:1216)
==26825== by 0x1ED7237D: gst_base_transform_transform_caps (gstbasetransform.c:465)
==26825==
==26825== 1,048,576 bytes in 2 blocks are definitely lost in loss record 16,631 of 16,634
==26825== at 0x30B54F35: drm_intel_gem_bo_map (intel_bufmgr_gem.c:1485)
==26825== by 0x30B4A221: drm_intel_bo_map (intel_bufmgr.c:103)
==26825== by 0x6D37F5F7: intel_batchbuffer_reset (intel_batchbuffer.c:62)
==26825== by 0x6D37F721: intel_batchbuffer_new (intel_batchbuffer.c:112)
==26825== by 0x6D345805: i965_driver_data_init (i965_drv_video.c:7226)
==26825== by 0x6D34F53D: i965_Init (i965_drv_video.c:7498)
==26825== by 0x6D34F53D: __vaDriverInit_1_1 (i965_drv_video.c:7663)
==26825== by 0x5AE05258: ??? (in /usr/lib/x86_64-linux-gnu/libva.so.2.100.0)
==26825== by 0x5AE063C4: vaInitialize (in /usr/lib/x86_64-linux-gnu/libva.so.2.100.0)
==26825== by 0x6C1AABE7: vaapi_initialize (gstvaapiutils.c:112)
==26825== by 0x6C1A01C4: gst_vaapi_display_create_unlocked (gstvaapidisplay.c:913)
==26825== by 0x6C1A01C4: gst_vaapi_display_create (gstvaapidisplay.c:927)
==26825== by 0x6C1A01C4: gst_vaapi_display_new (gstvaapidisplay.c:1177)
==26825== by 0x6C177363: gst_vaapi_create_display_from_handle (gstvaapipluginutil.c:129)
==26825== by 0x6C177363: gst_vaapi_create_display_from_gl_context (gstvaapipluginutil.c:208)
==26825== by 0x6C177363: gst_vaapi_ensure_display (gstvaapipluginutil.c:341)
==26825== by 0x6C17528B: gst_vaapi_plugin_base_ensure_display (gstvaapipluginbase.c:395)
==26825==
==26825== 1,048,576 bytes in 2 blocks are definitely lost in loss record 16,632 of 16,634
==26825== at 0x30B54F35: drm_intel_gem_bo_map (intel_bufmgr_gem.c:1485)
==26825== by 0x30B4A221: drm_intel_bo_map (intel_bufmgr.c:103)
==26825== by 0x6D37F5F7: intel_batchbuffer_reset (intel_batchbuffer.c:62)
==26825== by 0x6D37F721: intel_batchbuffer_new (intel_batchbuffer.c:112)
==26825== by 0x6D34581B: i965_driver_data_init (i965_drv_video.c:7227)
==26825== by 0x6D34F53D: i965_Init (i965_drv_video.c:7498)
==26825== by 0x6D34F53D: __vaDriverInit_1_1 (i965_drv_video.c:7663)
==26825== by 0x5AE05258: ??? (in /usr/lib/x86_64-linux-gnu/libva.so.2.100.0)
==26825== by 0x5AE063C4: vaInitialize (in /usr/lib/x86_64-linux-gnu/libva.so.2.100.0)
==26825== by 0x6C1AABE7: vaapi_initialize (gstvaapiutils.c:112)
==26825== by 0x6C1A01C4: gst_vaapi_display_create_unlocked (gstvaapidisplay.c:913)
==26825== by 0x6C1A01C4: gst_vaapi_display_create (gstvaapidisplay.c:927)
==26825== by 0x6C1A01C4: gst_vaapi_display_new (gstvaapidisplay.c:1177)
==26825== by 0x6C177363: gst_vaapi_create_display_from_handle (gstvaapipluginutil.c:129)
==26825== by 0x6C177363: gst_vaapi_create_display_from_gl_context (gstvaapipluginutil.c:208)
==26825== by 0x6C177363: gst_vaapi_ensure_display (gstvaapipluginutil.c:341)
==26825== by 0x6C17528B: gst_vaapi_plugin_base_ensure_display (gstvaapipluginbase.c:395)
==26825==
==26825== 1,048,576 bytes in 2 blocks are definitely lost in loss record 16,633 of 16,634
==26825== at 0x30B54F35: drm_intel_gem_bo_map (intel_bufmgr_gem.c:1485)
==26825== by 0x30B4A221: drm_intel_bo_map (intel_bufmgr.c:103)
==26825== by 0x6D37F5F7: intel_batchbuffer_reset (intel_batchbuffer.c:62)
==26825== by 0x6D3062CD: gen75_mfd_decode_picture (gen75_mfd.c:3640)
==26825== by 0x5AE0781F: vaEndPicture (in /usr/lib/x86_64-linux-gnu/libva.so.2.100.0)
==26825== by 0x6C19CA02: gst_vaapi_picture_decode (gstvaapidecoder_objects.c:312)
==26825== by 0x6C195C5D: decode_current_picture (gstvaapidecoder_h264.c:1723)
==26825== by 0x6C195C5D: gst_vaapi_decoder_h264_end_frame (gstvaapidecoder_h264.c:4751)
==26825== by 0x6C18F272: do_decode_1 (gstvaapidecoder.c:249)
==26825== by 0x6C18F272: do_decode (gstvaapidecoder.c:277)
==26825== by 0x6C18F272: gst_vaapi_decoder_decode (gstvaapidecoder.c:1039)
==26825== by 0x6C1736E1: gst_vaapidecode_handle_frame (gstvaapidecode.c:722)
==26825== by 0x16877EA0: gst_video_decoder_decode_frame (gstvideodecoder.c:3416)
==26825== by 0x1688048E: gst_video_decoder_have_frame (gstvideodecoder.c:3348)
==26825== by 0x6C172299: gst_vaapidecode_parse_frame (gstvaapidecode.c:1164)
==26825== by 0x6C172299: gst_vaapidecode_parse (gstvaapidecode.c:1195)
==26825==
==26825== 3,145,728 bytes in 2 blocks are definitely lost in loss record 16,634 of 16,634
==26825== at 0x30B54F35: drm_intel_gem_bo_map (intel_bufmgr_gem.c:1485)
==26825== by 0x30B4A221: drm_intel_bo_map (intel_bufmgr.c:103)
==26825== by 0x6D344F09: i965_MapBuffer (i965_drv_video.c:3051)
==26825== by 0x5AE073C0: vaMapBuffer (in /usr/lib/x86_64-linux-gnu/libva.so.2.100.0)
==26825== by 0x6C1A4F13: _gst_vaapi_image_map (gstvaapiimage.c:554)
==26825== by 0x6C184BC9: map_vaapi_memory (gstvaapivideomemory.c:250)
==26825== by 0x6C184BC9: gst_video_meta_map_vaapi_memory (gstvaapivideomemory.c:326)
==26825== by 0x1686DB3E: gst_video_frame_map_id (video-frame.c:103)
==26825== by 0x16871E28: gst_video_filter_transform (gstvideofilter.c:263)
==26825== by 0x1ED73400: default_generate_output (gstbasetransform.c:2132)
==26825== by 0x1ED72B83: gst_base_transform_chain (gstbasetransform.c:2285)
==26825== by 0x162FF89A: gst_pad_chain_data_unchecked (gstpad.c:4322)
==26825== by 0x162FF89A: gst_pad_push_data (gstpad.c:4578)
==26825== by 0x16307BC2: gst_pad_push (gstpad.c:4697) \