[Mesa-stable] [PATCH 2/2] mesa: don't leak performance monitors on context destroy
Ilia Mirkin
imirkin at alum.mit.edu
Fri Nov 29 02:52:27 PST 2013
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
Cc: "10.0" <mesa-stable at lists.freedesktop.org>
---
Found with valgrind. Don't have the hardware to test a real implementation,
but with nv50 it seemed to work in that valgrind was no longer marking the
hash table as leaked.
src/mesa/main/context.c | 1 +
src/mesa/main/performance_monitor.c | 19 +++++++++++++++++++
src/mesa/main/performance_monitor.h | 3 +++
3 files changed, 23 insertions(+)
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 87a4a35..658499f 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1194,6 +1194,7 @@ _mesa_free_context_data( struct gl_context *ctx )
_mesa_free_sync_data(ctx);
_mesa_free_varray_data(ctx);
_mesa_free_transform_feedback(ctx);
+ _mesa_free_performance_monitors(ctx);
_mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj, NULL);
_mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj, NULL);
diff --git a/src/mesa/main/performance_monitor.c b/src/mesa/main/performance_monitor.c
index 4981e6f..e62f770 100644
--- a/src/mesa/main/performance_monitor.c
+++ b/src/mesa/main/performance_monitor.c
@@ -93,6 +93,25 @@ fail:
return NULL;
}
+static void
+free_performance_monitor(GLuint key, void *data, void *user)
+{
+ struct gl_perf_monitor_object *m = data;
+ struct gl_context *ctx = user;
+
+ ralloc_free(m->ActiveGroups);
+ ralloc_free(m->ActiveCounters);
+ ctx->Driver.DeletePerfMonitor(ctx, m);
+}
+
+void
+_mesa_free_performance_monitors(struct gl_context *ctx)
+{
+ _mesa_HashDeleteAll(ctx->PerfMonitor.Monitors,
+ free_performance_monitor, ctx);
+ _mesa_DeleteHashTable(ctx->PerfMonitor.Monitors);
+}
+
static inline struct gl_perf_monitor_object *
lookup_monitor(struct gl_context *ctx, GLuint id)
{
diff --git a/src/mesa/main/performance_monitor.h b/src/mesa/main/performance_monitor.h
index a852a41..76234e5 100644
--- a/src/mesa/main/performance_monitor.h
+++ b/src/mesa/main/performance_monitor.h
@@ -35,6 +35,9 @@
extern void
_mesa_init_performance_monitors(struct gl_context *ctx);
+extern void
+_mesa_free_performance_monitors(struct gl_context *ctx);
+
extern void GLAPIENTRY
_mesa_GetPerfMonitorGroupsAMD(GLint *numGroups, GLsizei groupsSize,
GLuint *groups);
--
1.8.3.2
More information about the mesa-stable
mailing list