From: Carl Worth Date: Wed, 30 Oct 2013 21:35:21 +0000 (-0700) Subject: Fix resource leaks when switching contexts. X-Git-Url: https://git.cworth.org/git?p=fips;a=commitdiff_plain;h=402fa1d53531bd911eaacddca109d5d551ac7c2d Fix resource leaks when switching contexts. 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. --- diff --git a/metrics.c b/metrics.c index 9b94eb6..87da778 100644 --- 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); }