From patchwork Tue Sep 14 12:17:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13846 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id A5CAFBDB1D for ; Tue, 14 Sep 2021 12:17:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 76A4A6918E; Tue, 14 Sep 2021 14:17:20 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="IMzBew5v"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C52EB60249 for ; Tue, 14 Sep 2021 14:17:18 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.251.226.94]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BB1222A5; Tue, 14 Sep 2021 14:17:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1631621838; bh=6SRV+8Wn8GmIzPDhZOaCy5e8PjQ0Rtio4hjNnuU4ylA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IMzBew5vbF8TLrprbNhL+6So/vnXGFEbzmky0sJh6St6iVN5CilTTRbDsFdxggdYC UtNTKiLrAZ/43tU5FMxxw7Nimk2fSDkb8dJ/QjNBHNIleNnNW5S5uT9IeZN0wXPPT7 FoZhlQh6qyDdglvmZMcSv1TzEbQlGQdZnsOdGFUE= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Tue, 14 Sep 2021 17:47:00 +0530 Message-Id: <20210914121700.122591-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210914121700.122591-1-umang.jain@ideasonboard.com> References: <20210914121700.122591-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] test: gstreamer_single_stream_test: Fix memory leak X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 Reviewed-by: Nicolas Dufresne --- 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_;