Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wxTimer usage leads to excessive CPU usage when app is idle #11315

Closed
wxtrac opened this issue Oct 12, 2009 · 5 comments
Closed

wxTimer usage leads to excessive CPU usage when app is idle #11315

wxtrac opened this issue Oct 12, 2009 · 5 comments

Comments

@wxtrac
Copy link
Collaborator

@wxtrac wxtrac commented Oct 12, 2009

Issue migrated from trac ticket # 11315

component: wxGTK | priority: normal | resolution: fixed

2009-10-12 17:46:35: mschwendt created the issue


There have been bug reports about Audacity, which uses wxWidgets/GTK2, pointing out that if the application is left idle for some time, CPU usage will increase slowly but steadily.

One thread discusses it here:
http://sourceforge.net/mailarchive/message.php?msg_name=20091011120400.2fad6a52%40faldor.intranet

[...]

I've found out that AMule is affected, too. What AMule and Audacity have in common is that they use wxTimer.

[...]

wxTimer timeout callback runs wxApp::WakeUpIdle() which in turn runs wxapp_install_idle_handler() which causes more and more wxAddEmissionHook()'s to pile up. Due to that, wxGTK spends an increasing time in glib2's g_signal_add_emission_hook(). Only when touching the application or giving it focus, event_emission_hook() gets called and removes hooks by returning False.

@wxtrac
Copy link
Collaborator Author

@wxtrac wxtrac commented Oct 12, 2009

2009-10-12 18:00:17: mschwendt changed title from wxTimer usage leaders to excessive CPU usage when app is idle to wxTimer usage leads to excessive CPU usage when app is idle

@wxtrac
Copy link
Collaborator Author

@wxtrac wxtrac commented Oct 12, 2009

2009-10-12 18:39:32: aldimond (Al Dimond) commented


Just to be specific about this, an increasing amount of time (up to 100% CPU if left idle for long enough) is spent in g_hook_insert_before(), appending a GHook node to a linked list. This list grows quite large (240,000 nodes in 15 minutes of idling on my system, for example), and the increasing length of the list is the reason that CPU usage gradually increases.

@wxtrac
Copy link
Collaborator Author

@wxtrac wxtrac commented Oct 12, 2009

2009-10-12 19:26:55: @RobinD42 changed status from new to confirmed

2009-10-12 19:26:55: @RobinD42 commented

This has also been reported by wxPython users with wxStyledTextCtrl in their apps. wxStyledTextCtrl has a timer that is used for things like flashing the caret.

@wxtrac
Copy link
Collaborator Author

@wxtrac wxtrac commented Oct 12, 2009

2009-10-12 20:04:52: @paulcor changed status from confirmed to accepted

@wxtrac
Copy link
Collaborator Author

@wxtrac wxtrac commented Oct 13, 2009

2009-10-13 08:53:19: @paulcor changed status from accepted to closed

2009-10-13 08:53:19: @paulcor changed resolution from ** to fixed

2009-10-13 08:53:19: @paulcor commented

(In [62397]) Avoid installing emission hook more than once.
It was possible for an app using a timer, but triggering no events, to
accumulate an unbounded number of hooks, consuming large amounts of CPU time
in processing the hook list.
Fixes #11315.

@wxtrac wxtrac closed this Oct 13, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant