[libcamera-devel] [PATCH 2/2] test: gstreamer_single_stream_test: Fix memory leak
Umang Jain
umang.jain at ideasonboard.com
Tue Sep 14 14:17:00 CEST 2021
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:
==95352== definitely lost: 1,688 bytes in 2 blocks
==95352== indirectly lost: 11,901 bytes in 37 blocks
The patch fixes the leaks reported by valgrind above to:
==120397== definitely lost: 0 bytes in 0 blocks
==120397== indirectly lost: 0 bytes in 0 blocks
Signed-off-by: Umang Jain <umang.jain 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 d992455c..763a77b1 100644
--- a/test/gstreamer/gstreamer_single_stream_test.cpp
+++ b/test/gstreamer/gstreamer_single_stream_test.cpp
@@ -70,6 +70,12 @@ protected:
return TestPass;
}
+ void cleanup() override
+ {
+ gst_object_unref(convert0_);
+ gst_object_unref(sink0_);
+ }
+
private:
GstElement *convert0_;
GstElement *sink0_;
--
2.31.1
More information about the libcamera-devel
mailing list