From: Olivier Andrieu Message-ID: <17217.4772.442804.374366 at karryall.dnsalias.org> Date: Mon, 3 Oct 2005 13:14:44 +0200 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="JRU3dWKsG3" Content-Transfer-Encoding: 7bit To: Sebastien Ferre Cc: lablgtk at math.nagoya-u.ac.jp Subject: Re: GTree: delaying the computation of a pixbuf upon visibility In-Reply-To: <4340EEAA.8060904 at irisa.fr> References: <43355ED4.5000004 at inria.fr> <433A46AE.8000004@irisa.fr> <17211.57896.40053.753344@karryall.dnsalias.org> <433CF2BA.8030204@irisa.fr> <17215.60406.276599.274837@karryall.dnsalias.org> <4340EEAA.8060904@irisa.fr> --JRU3dWKsG3 Content-Type: text/plain; charset=us-ascii Content-Description: message body and .signature Content-Transfer-Encoding: 7bit Sebastien Ferre [Monday 3 October 2005] : > > Olivier Andrieu wrote: > > Sebastien Ferre [Friday 30 September 2005] : > > > > > > Hi, > > > > > > Olivier Andrieu wrote: > > > > Sebastien Ferre [Wednesday 28 September 2005] : > > > > > > > > > > Hi, > > > > > > > > > > I'm working on a GUI in which there is a 'GTree.list_store' of > > > > > thumbnails (look at http://www.irisa.fr/lande/ferre/camelis > > > > > for screen captions). I use the library CamlImages for > > > > > computing these thumbnails from JPEG pictures. > > > > > > > > Why don't you use GdkPixbuf for this ? It can load JPEG pictures. > > > > > > this is what I used at the beginning. But I noticed there was > > > something like a memory leak as the process rapidly grew to more > > > than 1Gb of memory, while I checked the loaded images were no more > > > reachable. > > > > Ah. It might be a memory leak in lablgtk. I'd be interested if > > you still have some code showing this problem. > > If you call many times the function 'pixmap_of_picture', you should > exhibit the problem. It seems the data in local variable 'pixbuf' > is never deallocated (while the use of Gc.finalize shows it do > become unreachable, as expected). Argl. OK I remember: indeed GdkPixbuf.from_file had a leak in lablgtk 2.4.0 (the pixbuf was referenced before being returned to caml and thus never deallocated). I fixed this in the first snapshot after lablgtk 2.4.0 (2004-11-19). But later, when I added support for serialisation of GdkPixbufs, I inadvertently broke the reference counting. This means that with the latest snapshot all functions creating pixbufs (like GdkPixbuf.copy, new_from_file, etc.) leak the pixbuf. (This will be fixed in the next version of course). > > > Also, CamlImages allows for loading directly a thumbnail from > > > JPEG pictures, which is lighter. > > > > GdkPixbuf has a GdkPixbuf.from_file_at_size function that lets > > you do that too (I hope so). > > I can't find it. Is it in a newer version ? (I have version 2.4.0). Yes it's in newer versions. So, could you do this: - download the lastest lablgtk snapshot http://wwwfun.kurims.kyoto-u.ac.jp/soft/olabl/dist/lablgtk2-20050701.tar.gz - apply the attached patch to fix the pixbuf refcounting - compile, install - test your program with GdkPixbuf.new_from_file/GdkPixbuf.scale : it shouldn't leak anymore - test your program with GdkPixbuf.new_from_file_at_size -- Olivier --JRU3dWKsG3 Content-Type: text/plain Content-Disposition: attachment; filename="gdk-pixbuf-refcount.patch" Content-Transfer-Encoding: 7bit Index: src/ml_gdkpixbuf.h =================================================================== RCS file: /staff2/garrigue/repos/lablgtk/src/ml_gdkpixbuf.h,v retrieving revision 1.5 diff -u -r1.5 ml_gdkpixbuf.h --- src/ml_gdkpixbuf.h 3 May 2005 20:50:21 -0000 1.5 +++ src/ml_gdkpixbuf.h 3 Oct 2005 11:03:50 -0000 @@ -2,5 +2,5 @@ #define GdkPixbuf_val(val) (check_cast(GDK_PIXBUF, val)) value Val_GdkPixbuf_ (GdkPixbuf *, gboolean); -#define Val_GdkPixbuf(p) Val_GdkPixbuf_(p, FALSE) -#define Val_GdkPixbuf_new(p) Val_GdkPixbuf_(p, TRUE) +#define Val_GdkPixbuf(p) Val_GdkPixbuf_(p, TRUE) +#define Val_GdkPixbuf_new(p) Val_GdkPixbuf_(p, FALSE) --JRU3dWKsG3--