[prev in list] [next in list] [prev in thread] [next in thread]
List: gtk-app-devel
Subject: Re: Run Loop Memory Management
From: jcupitt () gmail ! com
Date: 2007-05-30 10:37:38
Message-ID: 522c6460705300337p579f1139g3cb544f960deb194 () mail ! gmail ! com
[Download RAW message or body]
On 5/30/07, Brian J. Tarricone <bjt23@cornell.edu> wrote:
> Using an idle
> function will chew through CPU cycles while the application is
> otherwise idle (really hurts laptop battery performance, for one
> thing). Another option is a timeout using g_timeout_add(), but the
> correct approach would be to add a custom GSource that is only invoked
> when it needs to be.
I have a (slightly) similar problem with my application. It has (my
own) LISP-like programming language embedded for scripting. The
problem is when to trigger a garbage collect (other than on heap-full,
of course).
When I start processing something I use g_idle_add() to add a run-once
idle handler. When this fires, it does a g_timeout_add() with a 1
second delay. If there's already a timeout running, it destroys the
old timeout and sets a new one. Finally, when the timeout fires, it
does the garbage collect.
With this scheme you get the cleanup after a second of inactivity, and
no busy-waiting, which works for me, anyway. You'd need to watch out
for things like flashing cursors delaying cleanup forever I guess.
John
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic