memory leak in gdkpixmap.c




Suppose you were to:

	1. Create a large pixmap with gdk_pixmap_new()
	2. Draw stuff in it
	3. Blit it to the screen with gdk_draw_pixmap()
	4. Annihilate it with gdk_pixmap_destroy()
	5. Repeat frequently

You would discover that your X server rapidly consumes all available
memory.  I believe the following patch rectifies the problem, but
someone who understands the ref counting better than I do should
sanity check it.

Dan Risacher

-- 
I wonder if man will walk on the moon in my lifetime?


*** gdkpixmap.c.old     Sun Oct 26 00:09:01 1997
--- gdkpixmap.c Sun Oct 26 00:09:27 1997
***************
*** 628,641 ****
    g_return_if_fail (pixmap != NULL);
  
    private = (GdkPixmapPrivate*) pixmap;
    if (private->ref_count <= 0)
      {
        XFreePixmap (private->xdisplay, private->xwindow);
        gdk_xid_table_remove (private->xwindow);
        g_free (pixmap);
-     }
-   else
-     {
-       private->ref_count -= 1;
      }
  }
--- 628,638 ----
    g_return_if_fail (pixmap != NULL);
  
    private = (GdkPixmapPrivate*) pixmap;
+   private->ref_count -= 1;
    if (private->ref_count <= 0)
      {
        XFreePixmap (private->xdisplay, private->xwindow);
        gdk_xid_table_remove (private->xwindow);
        g_free (pixmap);
      }
  }



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