[libcamera-devel] [PATCH v2 1/3] test: gstreamer_single_stream_test: Fix memory leak

paul.elder at ideasonboard.com paul.elder at ideasonboard.com
Wed Sep 22 06:55:29 CEST 2021


Hi Vedant,

On Tue, Sep 21, 2021 at 11:09:53PM +0530, Vedant Paranjape wrote:
> The test hold a valid reference to convert0_ and sink0_ but
> not released. This results in a memory leak and can be checked
> via valgrind. Drop the references with test cleanup() virtual
> function.
> 
> Valgrind log (glib and gst suppression files were used):
> ==345380== LEAK SUMMARY:
> ==345380==    definitely lost: 1,688 bytes in 2 blocks
> ==345380==    indirectly lost: 7,069 bytes in 42 blocks
> 
> The patch fixes the leaks reported by valgrind above to:
> ==348870== LEAK SUMMARY:
> ==348870==    definitely lost: 0 bytes in 0 blocks
> ==348870==    indirectly lost: 0 bytes in 0 blocks
> 
> Signed-off-by: Vedant Paranjape <vedantparanjape160201 at gmail.com>
> Signed-off-by: Umang Jain <umang.jain at ideasonboard.com>
> Reviewed-by: Nicolas Dufresne <nicolas.dufresne at collabora.com>

Reviewed-by: Paul Elder <paul.elder at ideasonboard.com>

> ---
>  test/gstreamer/gstreamer_single_stream_test.cpp | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/test/gstreamer/gstreamer_single_stream_test.cpp b/test/gstreamer/gstreamer_single_stream_test.cpp
> index 7292f3280617..2b561d6bf9f2 100644
> --- a/test/gstreamer/gstreamer_single_stream_test.cpp
> +++ b/test/gstreamer/gstreamer_single_stream_test.cpp
> @@ -72,6 +72,12 @@ protected:
>  		return TestPass;
>  	}
>  
> +	void cleanup() override
> +	{
> +		g_clear_object(&convert0_);
> +		g_clear_object(&sink0_);
> +	}
> +
>  private:
>  	GstElement *convert0_;
>  	GstElement *sink0_;
> -- 
> 2.25.1
> 


More information about the libcamera-devel mailing list