nvcodec: Mark class data as may-be-leaked to quiet the leaks tracer
authorNirbheek Chauhan <nirbheek@centricular.com>
Tue, 11 Feb 2020 18:30:51 +0000 (00:00 +0530)
committerNirbheek Chauhan <nirbheek@centricular.com>
Tue, 11 Feb 2020 18:30:51 +0000 (00:00 +0530)
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
sys/nvcodec/gstnvh264enc.c
sys/nvcodec/gstnvh265enc.c

index 4bf4abe..6a4d102 100644 (file)
@@ -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));
index 242e3b6..b1bceeb 100644 (file)
@@ -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");
index 4a1e716..5d7d032 100644 (file)
@@ -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");