From 266dc415964a2fe7d87fc5e8f140763b87076797 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 12 Feb 2020 00:00:51 +0530 Subject: [PATCH] nvcodec: Mark class data as may-be-leaked to quiet the leaks tracer The class data with the caps in it will be leaked if the element is registered but never instantiated. There is no way around this. Mark the caps as such so that the leaks tracer does not warn about it. This is the same as pad template caps getting leaked, which are also marked as may-be-leaked. These objects are initialized exactly once, and are 'global' data. --- sys/nvcodec/gstnvdec.c | 3 +++ sys/nvcodec/gstnvh264enc.c | 3 +++ sys/nvcodec/gstnvh265enc.c | 3 +++ 3 files changed, 9 insertions(+) diff --git a/sys/nvcodec/gstnvdec.c b/sys/nvcodec/gstnvdec.c index 4bf4abe..6a4d102 100644 --- a/sys/nvcodec/gstnvdec.c +++ b/sys/nvcodec/gstnvdec.c @@ -1413,6 +1413,9 @@ gst_nvdec_subclass_register (GstPlugin * plugin, GType type, cdata->codec_type = codec_type; cdata->codec = g_strdup (codec); cdata->cuda_device_id = device_id; + /* class data will be leaked if the element never gets instantiated */ + GST_MINI_OBJECT_FLAG_SET (sink_caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED); + GST_MINI_OBJECT_FLAG_SET (src_caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED); g_type_query (type, &type_query); memset (&type_info, 0, sizeof (type_info)); diff --git a/sys/nvcodec/gstnvh264enc.c b/sys/nvcodec/gstnvh264enc.c index 242e3b6..b1bceeb 100644 --- a/sys/nvcodec/gstnvh264enc.c +++ b/sys/nvcodec/gstnvh264enc.c @@ -643,6 +643,9 @@ gst_nv_h264_enc_register (GstPlugin * plugin, guint device_id, guint rank, cdata->sink_caps = gst_caps_ref (sink_caps); cdata->src_caps = gst_caps_ref (src_caps); type_info.class_data = cdata; + /* class data will be leaked if the element never gets instantiated */ + GST_MINI_OBJECT_FLAG_SET (sink_caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED); + GST_MINI_OBJECT_FLAG_SET (src_caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED); type_name = g_strdup ("GstNvH264Enc"); feature_name = g_strdup ("nvh264enc"); diff --git a/sys/nvcodec/gstnvh265enc.c b/sys/nvcodec/gstnvh265enc.c index 4a1e716..5d7d032 100644 --- a/sys/nvcodec/gstnvh265enc.c +++ b/sys/nvcodec/gstnvh265enc.c @@ -798,6 +798,9 @@ gst_nv_h265_enc_register (GstPlugin * plugin, guint device_id, guint rank, cdata->sink_caps = gst_caps_ref (sink_caps); cdata->src_caps = gst_caps_ref (src_caps); type_info.class_data = cdata; + /* class data will be leaked if the element never gets instantiated */ + GST_MINI_OBJECT_FLAG_SET (sink_caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED); + GST_MINI_OBJECT_FLAG_SET (src_caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED); type_name = g_strdup ("GstNvH265Enc"); feature_name = g_strdup ("nvh265enc"); -- 2.7.4