caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] lablgtk2 & GC compact
@ 2004-09-03 12:32 Shivkumar Chandrasekaran
  2004-09-05 22:37 ` Olivier Andrieu
  0 siblings, 1 reply; 2+ messages in thread
From: Shivkumar Chandrasekaran @ 2004-09-03 12:32 UTC (permalink / raw)
  To: caml-list

Hi,

I read in SooHyoung Oh's excellent lablgtk2 tutorial that automatic 
compaction was turned off in lablgtk2, and that to get compaction we 
must call Gc.compact manually inside the callbacks. Is this true?

If so, how do I turn "automatic compaction" back on once I enter the 
callback, and off when I exit it? The manual seems to suggest
    |Gc.set { (Gc.get()) with Gc.max_overhead = 500 }
as the way to turn it on to automatic, and|||
||    |Gc.set { (Gc.get()) with Gc.max_overhead = |||||||1000000| }
the way to turn it off again. Is this the right thing to do with lablgtk2?

Thanks for any help.

--shiv--

|

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] lablgtk2 & GC compact
  2004-09-03 12:32 [Caml-list] lablgtk2 & GC compact Shivkumar Chandrasekaran
@ 2004-09-05 22:37 ` Olivier Andrieu
  0 siblings, 0 replies; 2+ messages in thread
From: Olivier Andrieu @ 2004-09-05 22:37 UTC (permalink / raw)
  To: shiv; +Cc: caml-list

 Shivkumar Chandrasekaran [Fri, 03 Sep 2004]:
 > I read in SooHyoung Oh's excellent lablgtk2 tutorial that automatic
 > compaction was turned off in lablgtk2, and that to get compaction
 > we must call Gc.compact manually inside the callbacks. Is this
 > true?

Well, not with any callback. You have to be sure that higher in the
call stack no GTK function holds a pointer to one of those structures
that LablGTK keeps in the caml major heap (GdkColor, GtkTreeIter,
GtkTextIter mainly). That's not so easy to make sure.

 > If so, how do I turn "automatic compaction" back on once I enter the 
 > callback, and off when I exit it? The manual seems to suggest
 >     Gc.set { (Gc.get()) with Gc.max_overhead = 500 }
 > as the way to turn it on to automatic, and
 >     Gc.set { (Gc.get()) with Gc.max_overhead = 1000000 }
 > the way to turn it off again. Is this the right thing to do with
 > lablgtk2?

Yes you could do this but of course you'll get a compaction only if a
major GC cycle occurs during the callback (and the conditions for a
compaction are met).

No, I think the idea is rather to let automatic compaction disabled
and do manual compaction sometimes. I think it is safe to do so inside
a glib timeout, so you could use this to have a compaction happen
every hour :

  Glib.Timeout.add ~ms:(1000 * 60 * 60) 
    ~callback:(fun () -> Gc.compact () ; true)

-- 
   Olivier

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-09-05 22:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-03 12:32 [Caml-list] lablgtk2 & GC compact Shivkumar Chandrasekaran
2004-09-05 22:37 ` Olivier Andrieu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).