Re: Correct use of pixbuf, pixmap, and image?



On Mar 20, 2006, at 3:59 PM, Ari Jolma wrote:

muppet wrote:

Ari Jolma wrote:

looking at process info, it seems that X is piling up memory, the code
   $self->{pixmap} = $self->{pixbuf}->render_pixmap_and_mask;
   $self->{image}->set_from_pixmap($self->{pixmap});

I've still seem to have a problem with this. I did a bit of  
research and it seems that GtkImage's set_from_pixmap increases the  
ref_count of the pixmap, thus the pixmap ends up with two ref_count  
two (I build NOISY Glib to confirm this) and thus X does not free  
its memory.
Yes.  Because there's one reference owned by the GtkImage and another  
owned by the perl scalar wrapper, which is held by the $self instance  
hash.  The pixmap will not be freed until *both* of these references  
are released.

Is there a way to unset the pixmap from the image or force the destroying of the pixmap? Recreating the image at this point in code does not work right away.
You can unset the GtkImage with

   $self->{image}->set_from_pixbuf (undef, undef);

but you'll still need to release the pixmap from $self with

   $self->{pixmap} = undef;

or

   delete $self->{pixmap};



--
Examples really shouldn't include unexploded ordnance.
  -- Joe Smith, referring to an example program i wrote.




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