http://www.perlmonks.org?node_id=1067428


in reply to Re^3: ActivePerl Gtk2::Helper Hangs
in thread ActivePerl Gtk2::Helper Hangs

I would try to remove the "while (Gtk2->events_pending()) {Gtk2->main_iteration();}", it is a waste of memory/stack recursion and CPU. repeat_call is called from a 10 ms timer, from the event loop. When repeat_call returns, more events will run automatically. "while (Gtk2->events_pending()) {Gtk2->main_iteration();}" is to make the app responsive when doing CPU intensive data processing in a single thread. It isn't for generic eventloops running (which is Gtk2->main();). By putting "while (Gtk2->events_pending()) {Gtk2->main_iteration();}" in an event handler, you basically wrote
sub foo { #process the event if(rand() > 0.5) { foo(); } } foo();
0.5 might be anywhere from 0.001 to 0.9. IDK what it will be in your app. Never do something with recursion when it can be processed with a loop. You will blow the stack of whatever language you are using. Perl might, but no guarantee of it doing this, give you a "Deep recursion on subroutine "%s"" warning, see Deep recursion on subroutine "%s".