| Ticket UUID: | 31085d2747c86255545d4da96c0743bb8eb13859 | |||
| Title: | Unexpected behavior after creating around 10000 ttk::labels on Windows | |||
| Type: | Bug | Version: | 8.6.9 | |
| Submitter: | SoleSoul | Created on: | 2020-09-07 07:55:26 | |
| Subsystem: | 88. Themed Tk | Assigned To: | nobody | |
| Priority: | 5 Medium | Severity: | Important | |
| Status: | Closed | Last Modified: | 2026-10-23 12:29:42 | |
| Resolution: | Fixed | Closed By: | jan.nijtmans | |
| Closed on: | 2026-10-23 12:29:42 | |||
| Description: |
TCL/TK version: 8.6.9
OS: Windows 10
Found in tkinter (Python 3.8), but reproducible in pure TCL.
Observation:
After creating around 10000 widgets (verified with ttk::label), comboboxes won't open, and newly created widgets won't be 'grid'ed on the window. Sometimes graphical artifacts appear outside the application window.
No error message or exception is raised.
Expected:
Either the limit can be removed, or at least document and return runtime errors to prevent the weird behavior.
Why is such a large number required:
We have a data heavy application which dynamically creates widgets according to changing data, and the application is in constant risk of failing. The size of the data is determined by the customer.
How to reproduce:
Take a working application, and add to its source, before the window is built, the following code:
for {set i 0} {$i < 10000} {incr i} {
ttk::label ".l$i" -text problematic
}
The number 10000 is the limit found, feel free to play with it.
Issue opened on Python's tkinter (rightfully closed as third party): https://bugs.python.org/issue41632
Related StackOverflow question (on tkinter): https://stackoverflow.com/questions/51486281/tkinter-maximum-number-of-widgets
| |||
| User Comments: |
jan.nijtmans added on 2026-10-23 12:29:42:
Sorry, that bisect points to another ticket: [1348333] This one is OK! jan.nijtmans added on 2026-10-23 12:26:32: fossil bisect chart 1 BAD 2026-10-23 09:20:10 6d6d38074ea28fcb 7 CURRENT 2026-10-23 08:55:12 73142d715206a61b 4 BAD 2026-10-23 08:42:11 bdb7edf927982f35 5 BAD 2026-10-22 18:23:16 fb166f9f73106ab2 6 BAD 2026-10-22 17:32:35 4b3b840a41badb6a 3 GOOD 2026-10-22 15:14:16 51a8eab8eee4e121 2 GOOD 2026-10-21 15:23:43 b8fb1d6c114cce4a jan.nijtmans added on 2026-10-23 12:25:49: I'm seeing a hang in textWind-17.10. Investigating! serhiy.storchaka added on 2026-10-23 10:16:38: Merged into main [92ccdec3f2], 9.0 [3efcdcac36] and 8.6 [3d4a73e5eb]. jan.nijtmans added on 2026-10-19 17:24:47: Re-opened. Didn't know what happened oehhar added on 2026-10-19 17:03:19: Jan, you have closed the solution branch head checkin [ee0b7a51]. Do you have any reason for this? CI is still scheduled. Didn't it work out? Thanks for all, Harald serhiy.storchaka added on 2026-09-18 13:30:20: Every Tk widget uses one window handle on Windows, and a process is limited to 10000 USER handles by default (USERProcessHandleQuota in the registry, up to 18000). Nothing can be done about it for mapped widgets. But ttk widgets created their window at creation time, so 10000 widgets that were never mapped also hit the limit, while classic widgets create their window only when mapped. Fixed on branch ttk-lazy-window-creation in [7fc6686e76]: ttk widgets now behave like classic widgets, which also makes their creation on Windows about 10 times faster. Note that after this change, as for classic widgets, event generate on a ttk widget that was never mapped has no effect. When the handle quota is exhausted, Tk still continues with invalid windows instead of reporting an error; this is a separate issue. fvogel added on 2020-09-07 19:38:50: It seems that chw in the chat said it all: [11:20] chw windows 10k window handles problem: see http://stackoverflow.com/questions/951419/ddg#951450 [11:20] chw each tk widget consumes a windows handle [11:20] chw a windows window handle [11:22] chw conclusion: Windows isn't appropriate for building huge sky scrapers, silos aren't a problem, but lack Windows --> there is probably no hope about this ticket for Windows. Contributions in the chat also mentioned that Linux and macOS don't exhibit the issue. SoleSoul added on 2020-09-07 08:39:06: sebres: looks like some issue of ttk:widgets, testing the same with tk- (not ttk::-) label works fine and doesn't show the behavior: nor the "freeze" in window, neither the creating time growing (ca 50µs/# constantly) SoleSoul added on 2020-09-07 08:29:30: Another quote from IRC with details about the issue:
sebres:
it is tk (at least for windows), repeat `time {ttk::label ".l[incr i]" -text demo} 1000` 10 times slowing down tk continuously, after 10th you cannot even enter console menu anymore
this seems to have some bottleneck by creation even, 600µs/# first run, 1500µs/# 10th run; single linked list?
same result with fresh compiled current core-8-6-branch (tcl and tk)
SoleSoul added on 2020-09-07 08:16:26: Quote from IRC - confirmations of the issue: avl42: I tried it with a tclkit 8.6.10 from equi4 with twapi on windows, and 8.6.8 default wish on ubuntu 18.04 on windows, after creating those 10000 labels (non-displayed) creating and gridding further widgets only re-arranged the toplevel's geometry but didn't show anything but gray background | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki