From c9d15fec7e5bc6c0eb2d736f467318c4fcacb17e Mon Sep 17 00:00:00 2001 From: Michael Tretter Date: Wed, 21 Oct 2020 11:42:54 +0200 Subject: [PATCH] glslstage: delete shader on finalize of stage GLSLstage creates the glShader using glCreateShader, but never calls glDeleteShader if the glShader is not used anymore. This forces the GL library to keep the compiled shader around, because it might be used in the future. Therefore, the glShader is leaked whenever a GLSLStage is destroyed. Fix the leak by deleting the glShader when finishing the GLSLStage. Part-of: --- gst-libs/gst/gl/gstglslstage.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gst-libs/gst/gl/gstglslstage.c b/gst-libs/gst/gl/gstglslstage.c index 2b08adb2d6..3e2d0e4991 100644 --- a/gst-libs/gst/gl/gstglslstage.c +++ b/gst-libs/gst/gl/gstglslstage.c @@ -74,12 +74,24 @@ G_DEFINE_TYPE_WITH_CODE (GstGLSLStage, gst_glsl_stage, GST_TYPE_OBJECT, GST_DEBUG_CATEGORY_INIT (gst_glsl_stage_debug, "glslstage", 0, "GLSL Stage");); +static void +_delete_shader (GstGLContext * context, GstGLSLStage * stage) +{ + GstGLSLStagePrivate *priv = stage->priv; + + if (priv->handle) + priv->vtable.DeleteShader (priv->handle); +} + static void gst_glsl_stage_finalize (GObject * object) { GstGLSLStage *stage = GST_GLSL_STAGE (object); gint i; + gst_gl_context_thread_add (stage->context, + (GstGLContextThreadFunc) _delete_shader, stage); + if (stage->context) { gst_object_unref (stage->context); stage->context = NULL;