clearing widgets from a container, possible memory leak
"Jacques Le Normand" <[email protected]>
| Newsgroups | gmane.comp.lang.ocaml.lib.gtk |
|---|---|
| Message-ID | <[email protected]> |
Hello lablgtk,
this is a small follow-up to the memory question I had earlier. The
difference is that I have a test case which increases its memory usage as
time goes on. Furthermore, it prints the memory usage
let repeat n f =
let rec rep i =
if i = n then [] else (f () :: rep (i+1))
in
rep 0
let container_clear c =
List.iter c#remove c#all_children
let _ =
let source_window = GWindow.window ~width:100 ~height:100 () in
let vbox = GPack.vbox ~packing:source_window#add () in
let inside = ref false in
let fill_vbox () =
if !inside then
()
else
begin
inside := true;
let add_entry () =
let ret = GEdit.entry ()
in
vbox#pack (ret:>GObj.widget);
ret
in
container_clear vbox;
print_endline (string_of_float (Gc.allocated_bytes ()));
ignore(repeat 100 add_entry);
inside:=false
end
in
ignore(Glib.Timeout.add 200 (fun () -> fill_vbox (); true));
source_window#show ();
GMain.Main.main ()
_______________________________________________
Lablgtk mailing list
[email protected]
http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk