Delivered-To: garrigue at math.nagoya-u.ac.jp Authentication-Results: mailhost.math.nagoya-u.ac.jp sender=lablgtk-bounces at yquem.inria.fr; domainkey=neutral (no query protocol specified; no policy for yquem.inria.fr) Delivered-To: lablgtk at yquem.inria.fr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=NmAOo2qdMxPnOH3ptueE90TZVn9U80m5KJorI/GTZcc=; b=r42VebybRZn05ErN9gl9Wtl68UrWOc+9vA4cXHQKJ2IWckTIByBgqp6y2ck1IkT8yC 6i5IlLe7HASfja5Sx3PrbFYYH+wIeH53fRzwl8O704lrbcQ0SDlwP1ghLu6hro6baAqd dEUf8UbOWz7JKyCbC5ihmZL0Gix9SOS1miopM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=tTlQqea80PzER5ovbImD06ANAHu1XUZpt2VkvuhLS5R8oC2haLSfsEqPZ+pNfRoD05 lQXwVQ96yKcN8tiPkUGf2NdxAffitdh2eEfzN/ve6zSVayfPDMHowJk8rQ0tXXjl6Cqy TVqtuowRosobmkVJ5BmeYSOve2gF8WaMDMqfY= Message-ID: Date: Tue, 21 Oct 2008 23:27:38 -0400 From: "Jacques Le Normand" To: lablgtk at yquem.inria.fr MIME-Version: 1.0 Subject: [Lablgtk] memory and containers Content-Type: multipart/mixed; boundary="===============2001489386==" Mime-version: 1.0 --===============2001489386== Content-Type: multipart/alternative; boundary="----=_Part_8624_21937502.1224646059019" ------=_Part_8624_21937502.1224646059019 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello lablgtk, I'm currently writing an application which displays a mix of text and GEdit.entry widgets in a GText.view . It also changes what's displayed several times a second, forcing me to clear the buffer and insert new GEdit.entry. It seems that placing and removing many GEdit.entry from a GText.view starts taking up a lot of memory rather quickly. How can I fix this? I've written an example program that creates a window and that adds 100 GEdit.entry every time you press a key. Pressing a key many times shows this application taking upwards of 100 megabytes (and slowing down considerably). How can I fix this? here's the program: let repeat n f = let rec rep i = if i = n then () else (f () ; rep (i+1)) in rep 0 let clearTextBuffer (tb:GText.buffer) = let a = tb#start_iter in let b = tb#end_iter in tb#delete a b let _ = let source_window = GWindow.window ~width:100 ~height:100 () in let buffer = GText.buffer () in let view = GText.view ~buffer:buffer ~packing:source_window#add () in let fill_view () = let add_entry () = view#add_child_at_anchor (GEdit.entry () :> GObj.widget) (buffer#create_child_anchor (buffer#end_iter)); in clearTextBuffer buffer; repeat 100 add_entry; in ignore (view#event#connect#key_press ~callback:(fun _ -> fill_view ();false)); source_window#show (); GMain.Main.main () ------=_Part_8624_21937502.1224646059019 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello lablgtk,
I'm currently writing an application which displays a mix of text and GEdit.entry widgets in a GText.view . It also changes what's displayed several times a second, forcing me to clear the buffer and insert new GEdit.entry. It seems that placing and removing many GEdit.entry from a GText.view starts taking up a lot of memory rather quickly. How can I fix this? I've written an example program that creates a window and that adds 100 GEdit.entry every time  you press a key. Pressing a key many times shows this application taking upwards of 100 megabytes (and slowing down considerably). How can I fix this?
here's the program:

let repeat n f =
  let rec rep i =
    if i = n then () else (f () ; rep (i+1))
  in
    rep 0

let clearTextBuffer (tb:GText.buffer) =
  let a = tb#start_iter in
  let b  = tb#end_iter in
    tb#delete a b

let _ =
  let source_window = GWindow.window ~width:100 ~height:100 () in
  let buffer = GText.buffer () in
  let view = GText.view ~buffer:buffer ~packing:source_window#add  () in
  let fill_view () =
    let add_entry () =
      view#add_child_at_anchor (GEdit.entry () :> GObj.widget) (buffer#create_child_anchor (buffer#end_iter));
    in
      clearTextBuffer buffer;
      repeat 100 add_entry;     
  in
    ignore
      (view#event#connect#key_press
     ~callback:(fun _ -> fill_view ();false));
    source_window#show ();
    GMain.Main.main ()

------=_Part_8624_21937502.1224646059019-- --===============2001489386== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Lablgtk mailing list Lablgtk@yquem.inria.fr http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk --===============2001489386==--