The refcount patch [Was: memory leak in gdkpixmap.c]



Daniel R Risacher <risacher@worldnet.att.net> writes:

> 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.

Thanks for pointing this out.  The refcount patch

    ftp://ftp.gimp.org/pug/gtk/patches/gtk-mvo-971013-0.patch.gz  (?)

corrects this.

It also does away with the gdk_pixmap_destroy function.  Pixmaps are
viewed as resources that live as long as someone has a use for them.
Use gdk_pixmap_unref instead of gdk_pixmap_destroy.

Ok, now, I noticed that I have write access to the main Gtk source
repo.  Should I just go ahead and commit the patch?

The main problem is that it renames a bunch of *_destroy functions to
*_unref.  I would put in backward compatibility by making the
*_destroy functions identical to the *_unrefs, and spitting out a
warning at program exit that deprecated functions have been used.
When all important programs have been converted to unreffing, we can
remove the aliases.



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