Re: Releasing client-side pixmaps



Dag Helstad <dag helstad kreatel se> writes:

> Hi, I'm trying to minimize the memory usage of a GTK application which uses
> a GtkPixmap to show a background pixmap. 
> 
> The X server keeps a server-side copy of the pixmap, but it seems a
> client-side copy is kept in my application.
> 
> Here is the code fragment which creates a gtk_pixmap from my bitmap (which
> is stored in PNG format):
> 
> /****************************/
> GtkWidget* LoadImage(const std::string& location)
> {
>    GtkWidget* widget = NULL;
>    GdkPixbuf* image = NULL;
>    GdkPixmap* pixmap = NULL;
>    GdkBitmap* mask = NULL;
> 
>    image=gdk_pixbuf_new_from_file(location.c_str());
>    gdk_pixbuf_render_pixmap_and_mask(image, &pixmap, &mask, 100);
> 
>    widget = gtk_pixmap_new(pixmap, mask);
> 
>    gdk_pixmap_unref(pixmap);
>    gdk_bitmap_unref(mask);
>    gdk_pixbuf_unref(image);
>    
>    return widget;
> }
> /****************************/
> 
> I unref() the GdkPixbuf, GdkPixmap and GdkBitmap. Does the GtkPixmap widget
> keep a client-side copy of the pixmap? Can I free the client-side pixmap
> without destroying my GtkPixmap widget?

There are a client side wrapper objects that GTK+ uses to track the
server side pixmap and mask. They don't hold the data of the image,
just bookkeeping information. You can't get rid of them.

There is no other "client side pixmap".

Regards,
                                        Owen



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