Re: Multi-threaded gtk app very very slow



On Mon, 17 Jul 2006 20:10:05 +0200, Mark Richardson <markmapo yahoo com> wrote:

I have a multi-threaded application that I developed using gtk 2.4.1

I'm writing one of those myself, and funny things can happen. One important rule to remember is this:

Run all your GUI stuff in one thread only. Communication with other threads can be accomplished through idle functions.

At one time my app was behaving very badly. It segfaulted all the time, and gdb stack traces showed nothing but gtk/glib core functions. Later it turned out that some function in the non-GUI thread was stomping all over memory that had been free()d prematurely (and then, presumably, been given to the GUI thread via malloc()). From the debugger output it looked as if all was gtk's fault.

Moral: Beware. This is of course not a gtk-specific problem, but since gtk seems to allocate lots of bits of memory frequently, it will easily trip over memory corruption. This is, of course, not limited to multi-threaded programs, but those are a lot harder to debug.

robert



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]