From 14cd8b8348895bb542c6f5eac80aa7964be4e36a Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 13 Feb 2020 17:53:29 -0300 Subject: [PATCH] leaks: Do not trace refs for object we do not follow When the user sets filters, we should not trace ref counts of object that are not traced. This optimizes the tracer by potentially avoiding generating useless backtraces. --- plugins/tracers/gstleaks.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/plugins/tracers/gstleaks.c b/plugins/tracers/gstleaks.c index 3e279abc87..8afd14e7c7 100644 --- a/plugins/tracers/gstleaks.c +++ b/plugins/tracers/gstleaks.c @@ -413,8 +413,8 @@ object_created_cb (GstTracer * tracer, GstClockTime ts, GstObject * object) } static void -handle_object_reffed (GstLeaksTracer * self, gpointer object, gint new_refcount, - gboolean reffed, GstClockTime ts) +handle_object_reffed (GstLeaksTracer * self, gpointer object, GType type, + gint new_refcount, gboolean reffed, GstClockTime ts) { ObjectRefingInfos *infos; ObjectRefingInfo *refinfo; @@ -422,6 +422,9 @@ handle_object_reffed (GstLeaksTracer * self, gpointer object, gint new_refcount, if (!self->check_refs) return; + if (!should_handle_object_type (self, type)) + return; + GST_OBJECT_LOCK (self); infos = g_hash_table_lookup (self->objects, object); if (!infos) @@ -446,7 +449,8 @@ object_reffed_cb (GstTracer * tracer, GstClockTime ts, GstObject * object, { GstLeaksTracer *self = GST_LEAKS_TRACER_CAST (tracer); - handle_object_reffed (self, object, new_refcount, TRUE, ts); + handle_object_reffed (self, object, G_OBJECT_TYPE (object), new_refcount, + TRUE, ts); } static void @@ -455,7 +459,8 @@ object_unreffed_cb (GstTracer * tracer, GstClockTime ts, GstObject * object, { GstLeaksTracer *self = GST_LEAKS_TRACER_CAST (tracer); - handle_object_reffed (self, object, new_refcount, FALSE, ts); + handle_object_reffed (self, object, G_OBJECT_TYPE (object), new_refcount, + FALSE, ts); } static void @@ -464,7 +469,8 @@ mini_object_reffed_cb (GstTracer * tracer, GstClockTime ts, { GstLeaksTracer *self = GST_LEAKS_TRACER_CAST (tracer); - handle_object_reffed (self, object, new_refcount, TRUE, ts); + handle_object_reffed (self, object, GST_MINI_OBJECT_TYPE (object), + new_refcount, TRUE, ts); } static void @@ -473,7 +479,8 @@ mini_object_unreffed_cb (GstTracer * tracer, GstClockTime ts, { GstLeaksTracer *self = GST_LEAKS_TRACER_CAST (tracer); - handle_object_reffed (self, object, new_refcount, FALSE, ts); + handle_object_reffed (self, object, GST_MINI_OBJECT_TYPE (object), + new_refcount, FALSE, ts); } static void