|
2026-10-22
| ||
| 17:19 | • Ticket [5ee1a650b7] Memory usage degradations after enabling thread in TCL ... artifact: bcb657a1db user: serhiy.storchaka | |
|
2026-10-14
| ||
| 14:19 | • Closed ticket [5ee1a650b7]. artifact: d601218f8c user: serhiy.storchaka | |
|
2021-04-26
| ||
| 10:04 | • Ticket [5ee1a650b7]: 3 changes artifact: 2f2624a6b6 user: arvind29 | |
|
2021-04-16
| ||
| 15:04 | • Ticket [5ee1a650b7]: 3 changes artifact: c214a07f09 user: arvind29 | |
|
2021-04-08
| ||
| 10:50 | • Ticket [5ee1a650b7]: 3 changes artifact: 48b46b4bc3 user: sebres | |
| 04:29 | • Ticket [5ee1a650b7]: 3 changes artifact: 473f46c1c9 user: arvind29 | |
|
2021-04-07
| ||
| 17:29 | • Ticket [5ee1a650b7]: 3 changes artifact: 0011d71b2e user: arvind29 | |
| 17:27 | • New ticket [5ee1a650b7]. artifact: 5a7bcfc6ca user: arvind29 | |
Memory usage degradations after enabling thread in TCL
Memory degradation is happing in few test cases after configuring the TCL with "--enable_threads". So I wanted to know why memory is degrading with "--enable-threads". Please help.
What are you calling memory degradation?
1. If you rather mean that freed memory blocks are not released to system back, then it is indeed correct with threaded-alloc, but it is intended behavior - they will be put into common thread pool, so are reusable for further threads.
The "solution" is here only to build tcl with some custom memory manager (or redefine Tcl_Alloc, Tcl_Free etc as sys-calls alloc, free etc).
2. If you mean either certain memory fragmentation (e. g. like described here http://paste.tclers.tk/5260), then it is also known issue and work is in progress (I'll try to present new threaded-alloc memory manager soon).
Possible "solution" for that at the moment is the same as above.
3. And last but not least, some of your handling could be probably thread unsafe, so simply leaking on memory if something used multi-threaded. For instance, you cannot share tcl-objects across threads (it is only allowed to supply single reference of object from one thread to another, but not a common shared usage in both, see Tcl_DuplicateObj), let alone the tcl-interpreter or some other main Tcls instances, which must be also definitely owned by the single thread only.
Hi sebres, I have removed "#define USE_THREAD_ALLOC 1" from configure file and I have not seen any degradation. Is it safe to remove USE_THREAD_ALLOC from configure file. I am compiling TCL with --enable-threads option. Thanks much!
Yes, it is safe: without USE_THREAD_ALLOC, Tcl 8.6 uses the system malloc() and free(), which are thread-safe, but can be slower when many threads allocate at the same time. As sebres wrote, the threaded allocator keeps freed memory for reuse instead of returning it to the system; this is by design. The fragmentation problem is tracked in [3d1c409f1a].