]> git.cworth.org Git - fips/commitdiff
Fix resource leaks when switching contexts.
authorCarl Worth <cworth@cworth.org>
Wed, 30 Oct 2013 21:35:21 +0000 (14:35 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 31 Oct 2013 23:26:11 +0000 (16:26 -0700)
Previously, fips was already freeing memory that it had allocated for
its own linked lists of outstanding queries when switching contexts.

In addition, in this commit, we also now call End on any active
timer-query/performance-monitor and then call Delete on all queries
for which we have not previously collected results.

This avoids leaks within the OpenGL implementation as it holds on to
results that fips will never ask for.

metrics.c

index 9b94eb650ce9a48ee2ad4b9590eef28d07852f7a..87da77834854e915dadb557e46d0a45c1dc10bb8 100644 (file)
--- a/metrics.c
+++ b/metrics.c
@@ -332,6 +332,8 @@ metrics_info_fini (void)
                return;
 
        if (ctx->timer_begun_id) {
+               glEndQuery (GL_TIME_ELAPSED);
+               glDeleteQueries (1, &ctx->timer_begun_id);
                ctx->timer_begun_id = 0;
        }
 
@@ -339,6 +341,7 @@ metrics_info_fini (void)
             timer;
             timer = timer_next)
        {
+               glDeleteQueries (1, &timer->id);
                timer_next = timer->next;
                free (timer);
        }
@@ -346,6 +349,8 @@ metrics_info_fini (void)
        ctx->timer_tail = NULL;
 
        if (ctx->monitor_begun_id) {
+               glEndPerfMonitorAMD (ctx->monitor_begun_id);
+               glDeletePerfMonitorsAMD (1, &ctx->monitor_begun_id);
                ctx->monitor_begun_id = 0;
        }
 
@@ -353,6 +358,7 @@ metrics_info_fini (void)
             monitor;
             monitor = monitor_next)
        {
+               glDeletePerfMonitorsAMD (1, &monitor->id);
                monitor_next = monitor->next;
                free (monitor);
        }