Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
LablGTK app maxes out CPU
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-07-04 (20:00)
From: Matt Gushee <matt@g...>
Subject: Re: [Caml-list] LablGTK app maxes out CPU
Eric Cooper wrote:
> On Tue, Jul 04, 2006 at 12:30:11PM -0600, Matt Gushee wrote:
>> [...]
>> When the app is started but before the 
>> GUI is displayed for the first time, CPU usage is negligible, but as 
>> soon as the GUI is displayed, the app starts using all available CPU 
>> time, and it continues to do so as long as it runs, whether the GUI is 
>> displayed or not. So I wonder if there's something more I need to do to 
>> keep the app well-behaved (BTW, it should never require much CPU time. 
>> It's a lightweight file manager, and is graphical only in the sense that 
>> it is a GUI app--it uses no icons or other images).
> Try making the fd nonblocking before you create the glib channel:
>     Unix.set_nonblock msg_fd;

That's how it was originally. But if you look again at my code, you can 
see that the version with Unix.O_NONBLOCK is commented out. That's 
because on one of my machines (the one with a newer version of GTK and 
LablGTK, I believe), I got exceptions every time the program tried to 
read the input. I don't fully understand why, but making the channel 
non-non-blocking eliminated the errors. It doesn't make sense to 
me--based on my limited knowledge of how POSIX I/O works, the channel 
really *should* be non-blocking. But I have no idea what kind of magic 
Glib is doing behind the scenes.

Matt Gushee
: Bantam - lightweight file manager : :
: RASCL's A Simple Configuration Language : :