Delivered-To: lablgtk at yquem.inria.fr From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: lablgtk at yquem.inria.fr Subject: Re: [Lablgtk] Leaking pixmaps Date: Wed, 9 Jan 2008 12:48:05 +0000 References: <200801091053.51621.jon at ffconsultancy.com> In-Reply-To: <200801091053.51621.jon at ffconsultancy.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200801091248.05962.jon at ffconsultancy.com> Content-Type: text/plain; charset="iso-8859-1" Content-Length: 2118 On Wednesday 09 January 2008 10:53:51 Jon Harrop wrote: > Has anyone found a bug where using pixmaps causes a memory leak resulting > in X consuming all memory and dying? > > I just ditched pixmaps in favour of direct rendering which fixed the > problem and the symptom deterred me from investigating... Spoke too soon. The problem also appears without pixmaps. The following program tries to incrementally render randomly colored dots but, instead, just overloads X and kills my entire window system when I try to resize the window: (* ocamlopt -dtypes bigarray.cmxa -I +lablgtk2 lablgtk.cmxa gtkInit.cmx gtktest.ml -o gtktest *) let window = GWindow.window ~width:512 ~height:512 ~title:"Ray tracer" () let vbox = GPack.vbox ~packing:window#add () let drawing_area = GMisc.drawing_area ~packing:vbox#add () let drawable = drawing_area#misc#realize (); new GDraw.drawable drawing_area#misc#window let key_press key = if GdkEvent.Key.keyval key = GdkKeysyms._Escape then GMain.Main.quit(); false let paint ev = let rect = GdkEvent.Expose.area ev in let x = Gdk.Rectangle.x rect and y = Gdk.Rectangle.y rect in let w = Gdk.Rectangle.width rect and h = Gdk.Rectangle.height rect in let width, height = drawable#size in Printf.printf "(%d, %d) + (%d, %d): %d / %d\n%!" x y w h y height; for x = x to x + w - 1 do drawable#set_foreground (`RGB(Random.int 65536, Random.int 65536, Random.int 65536)); drawable#point ~x ~y; done; drawing_area#misc#draw(Some(Gdk.Rectangle.create x (y + 1) width (height - 1))); true let () = ignore(window#event#connect#key_press ~callback:key_press); ignore(window#connect#destroy ~callback:GMain.Main.quit); ignore(drawing_area#event#connect#expose ~callback:paint); window#show(); GMain.Main.main () Looks like the call to "drawable#set_foreground" is leaking resources like a sieve. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e _______________________________________________ Lablgtk mailing list Lablgtk@yquem.inria.fr http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk