From: Andy S. <laz...@gm...> - 2010-09-02 09:30:59
|
Hi Axel, Axel Simon <Axe...@in...> writes: > Hi Christian, > > On 17.07.2010, at 01:54, Christian Höner zu Siederdissen wrote: > >> Hi, >> >> the program below displays a problem. 'pixbufScaleSimple' generates a >> new Pixbuf every time it is called (here a 100 times). But once out of >> scope, these instances are not garbage-collected. >> >> How do I get them to be? >> > > I've tried your example below but removed a 0 from every number (where > possible). > > I've then turned on the DEBUG flag in hsgthread.c which then spits out > information on when objects go out of scope: > > *Main> main > .... > running 12 finalizers! > releasing lock to kill objects > > So your Pixbufs are enqueued correctly. However, we only free objects > when > mainGUI is called. We do this because some objects hold X11 resources > or Win32 resources and must be collected from the main GUI thread > (otherwise bad things will happen). In case of Pixbuf, this is a bit > unfortunate since they are retained until mainGUI although they could > be freed immediately. > >> Or, what I actually want: how to write an ImageViewer that loads >> lots of >> images? pixbufNewFromFile shows the same problem, but the program is >> larger ;-) >> > > I've enhanced our code generation for types that is used to specify > which constructor is used for a given object. I've then set the Pixbuf > related objects to use the default destructor that destroys the > objects immediately during GC (and not in the mainGUI loop). With this > patch your pixbufs will be GC'd as soon as they go out of scope and GC > runs. Have you test Christian's code after apply this patch? It's looks haven't any change with new patch. I have use pixbuf develop a Image-Viewer, below is screenshots: http://www.flickr.com/photos/48809572@N02/4947462492/lightbox/ Any "IO Pixbuf" function will cause memory leak, such as pixbufNewFromFile, pixbufRotateSimple. I think we should write some function to call g_object_unref help user release pixbuf's memory explicitly, otherwise pixbuf will eat all memory. Cheers, -- Andy |