patch to r200_context.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

We have experienced significant memory leaks when destroying gl contexts,
using the r200_dri.so driver.  Using a leak checker(Insure) we
found some memory not being freed in
 void r200DestroyContext( __DRIcontextPrivate *driContextPriv )
in xc/lib/GL/mesa/src/drv/r200/r200_context.c

This patch is for XFree86-Mesa-4.3.99.902-40.i586.rpm from a Suse 9.1
distribution.  After downloading and looking in XFree86-4.5.0-src-*.tgz,
it appears these memory leaks are still present in XFree86-4.5.0.

The following patch fixed these memory leaks for us.

Thanks,

Jonathan

--- lib/GL/mesa/src/drv/r200/r200_context.c.orig        2005-04-18
16:37:28.009570762 -0400
+++ lib/GL/mesa/src/drv/r200/r200_context.c     2005-04-18
16:37:35.383302928 -0400
@@ -463,7 +463,7 @@
       _tnl_DestroyContext( rmesa->glCtx );
       _ac_DestroyContext( rmesa->glCtx );
       _swrast_DestroyContext( rmesa->glCtx );
-
+      _ae_destroy_context( rmesa->glCtx );
       r200DestroySwtcl( rmesa->glCtx );
       r200ReleaseArrays( rmesa->glCtx, ~0 );

@@ -476,15 +476,6 @@
         if (!getenv("R200_NO_VTXFMT"))
            r200VtxfmtDestroy( rmesa->glCtx );

-      /* free the Mesa context */
-      rmesa->glCtx->DriverCtx = NULL;
-      _mesa_destroy_context( rmesa->glCtx );
-
-      if (rmesa->state.scissor.pClipRects) {
-        FREE(rmesa->state.scissor.pClipRects);
-        rmesa->state.scissor.pClipRects = 0;
-      }
-
       if ( release_texture_heaps ) {
          /* This share group is about to go away, free our private
           * texture object data.
@@ -499,6 +490,35 @@
         assert( is_empty_list( & rmesa->swapped ) );
       }

+      /* free the Mesa context */
+      rmesa->glCtx->DriverCtx = NULL;
+      _mesa_destroy_context( rmesa->glCtx );
+
+      if (rmesa->state.scissor.pClipRects) {
+        FREE(rmesa->state.scissor.pClipRects);
+        rmesa->state.scissor.pClipRects = 0;
+      }
+
+      /* BEGIN STOPPING MEMORY LEAKS */
+      {
+        struct r200_state_atom *pIter;
+        foreach (pIter, &rmesa->hw.dirty)
+        {
+          FREE(pIter->lastcmd);
+          FREE(pIter->cmd);
+        }
+        foreach (pIter, &rmesa->hw.clean)
+        {
+          FREE(pIter->lastcmd);
+          FREE(pIter->cmd);
+        }
+      }
+
+      _math_matrix_dtr( &rmesa->TexGenMatrix[0] );
+      _math_matrix_dtr( &rmesa->TexGenMatrix[1] );
+      _math_matrix_dtr( &rmesa->tmpmat );
+      /* END STOPPING MEMORY LEAKS */
+
       FREE( rmesa );
    }
 }

_______________________________________________
XFree86 mailing list
XFree86@xxxxxxxxxxx
http://XFree86.Org/mailman/listinfo/xfree86

[Index of Archives]     [X Forum]     [Xorg]     [XFree86 Newbie]     [IETF Announce]     [Security]     [Font Config]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux Kernel]

  Powered by Linux