Skip to content
Tcl Source Code History Of Ticket 3382401fffffffff
Login

History Of Ticket 3382401fffffffff

Artifacts Associated With Ticket 3382401fffffffff

  1. Ticket change [d8ad931e6b] (rid 107482) by auriocus on 2011-07-29 19:34:15:

    1. assignee initialized to: "vasiljevic"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Using thread pool to do a computation in parallel with many thousand tasks, I noticed, that tpool leaks memory. The script attached demonstrates the loss both in ActiveTcl 8.5.10.1 on Windows/64 and in tcl8.6 HEAD on Mac OSX. My real computation ran for several hours on 6 cores and the leaked memory summed up to several hundred MB. I could not locate the leakage any further, first I thought the culprit was the tpool::wait command with the list result, but replacing it with a simple "after" in the test case has no influence. Also, tpool::release can not free the leaked memory.
      
    4. foundin initialized to: "None"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "auriocus"
    10. subsystem initialized to: "80. Thread Package"
    11. title initialized to: "Thread pool leaks memory"
    12. type initialized to: "Bug"
  2. Ticket change [bc80e2f3a0] (rid 101761) by auriocus on 2011-07-30 02:34:15:

    1. icomment:
      
      
      File Added - 419726: threadpool_leakdemo.tcl
      
      
      
    2. login: "auriocus"
    3. mimetype: "text/plain"
    4. username: "auriocus"
  3. Add attachment "threadpool_leakdemo.tcl" [241ec5bac3] (rid 131061) by auriocus on 2011-07-30 02:34:15.

  4. Ticket change [4c722d41f4] (rid 126894) by vasiljevic on 2011-07-30 02:47:44:

    1. icomment:
      I cannot confirm this on Max OSX using Tcl8.4
      
      % array get tcl_platform
      osVersion 10.7.0 byteOrder littleEndian tip,268 1 threaded 1 machine i386 platform unix os Darwin tip,280 1 user zoran wordSize 4
      % set tcl_version
      8.4
      
      When I start your script it ocmplains about math max function.
      I remove that out of the code (it is not really related to anything
      thread-wise) and run the script. It allocates some 30MB virtual
      memory and stays there no matter howmany times i run your
      leak proc.
      
      I gues this has something to do with new(er) Tcl cores.  I have
      not tested anything later then 8.4.
      
      
      
      
    2. login: "vasiljevic"
    3. mimetype: "text/plain"
    4. username: "vasiljevic"
  5. Add attachment "threadpool_leakdemo84.tcl" [4e7a8fffd5] (rid 127239) by auriocus on 2011-07-30 03:05:44.

  6. Ticket change [78d4868a61] (rid 90029) by auriocus on 2011-07-30 03:05:45:

    1. icomment:
      
      
      File Added - 419729: threadpool_leakdemo84.tcl
      
      
      
    2. login: "auriocus"
    3. mimetype: "text/plain"
    4. username: "auriocus"
  7. Ticket change [b72e70c83b] (rid 125539) by auriocus on 2011-07-30 03:14:33:

    1. icomment:
      I've updated the script for 8.4 without max. If I run it with
      tclsh8.4 threadpool_leakdemo84.tcl
      then the value in activity monitor "physical memory" winds up, every ten seconds +0.1MB. It starts from 3.0 and goes up to 6MB. You are right that "virtual memory" does not change; I wonder, why.
      
      
    2. login: "auriocus"
    3. mimetype: "text/plain"
    4. username: "auriocus"
  8. Ticket change [7a42ea696e] (rid 90283) by auriocus on 2011-07-30 03:17:33:

    1. icomment:
      My platform:
      
      91-65-210-59-dynip:Programmieren chris$ tclsh8.4
      % parray tcl_platform
      tcl_platform(byteOrder) = littleEndian
      tcl_platform(machine)   = i386
      tcl_platform(os)        = Darwin
      tcl_platform(osVersion) = 10.8.0
      tcl_platform(platform)  = unix
      tcl_platform(threaded)  = 1
      tcl_platform(tip,268)   = 1
      tcl_platform(tip,280)   = 1
      tcl_platform(user)      = chris
      tcl_platform(wordSize)  = 4
      % 
      
      PS: Funny version. My OS is Snow Leopard 10.6.8, why does it say 10.8.0?
      
      
    2. login: "auriocus"
    3. mimetype: "text/plain"
    4. username: "auriocus"
  9. Ticket change [6b2b34e323] (rid 128272) by vasiljevic on 2011-07-30 03:46:43:

    1. icomment:
      The virtual memory is what counts. The real memory is
      not important here. If virtual memory does not increase
      you do not have leak.
      
      The OS versioning is weird by Mac, yes.
      I also have SnowLeopard but 10.6.7. This is no problem. 
      
      
      
      
    2. login: "vasiljevic"
    3. mimetype: "text/plain"
    4. username: "vasiljevic"
  10. Ticket change [3785faca24] (rid 107296) by auriocus on 2011-07-30 03:54:47:

    1. icomment:
      
      
      File Added - 419733: threadpool_leakdemo84_fast.tcl
      
      
      
    2. login: "auriocus"
    3. mimetype: "text/plain"
    4. username: "auriocus"
  11. Add attachment "threadpool_leakdemo84_fast.tcl" [db9b16975f] (rid 107990) by auriocus on 2011-07-30 03:54:47.

  12. Ticket change [6b0d03c38e] (rid 128249) by auriocus on 2011-07-30 03:55:57:

    1. icomment:
      OK, so try the third version. I shortened the inner loop and made more iterations. Now you'll see, that also virtual memory winds up.  
      
      
    2. login: "auriocus"
    3. mimetype: "text/plain"
    4. username: "auriocus"
  13. Ticket change [b852a2c1ff] (rid 128947) by vasiljevic on 2011-07-30 04:27:01:

    1. icomment:
      yes. this eats up memory somewhere. will double-check and fix.
      thanks for reporting this!
      
      
      
    2. login: "vasiljevic"
    3. mimetype: "text/plain"
    4. priority changed to: "7 High"
    5. resolution changed to: "Accepted"
    6. username: "vasiljevic"
  14. Ticket change [17d0949aad] (rid 122559) by vasiljevic on 2011-07-30 04:45:09:

    1. icomment:
      I think I would need to release a new version. My own private sandbox
      seems to work fine. The 2.6.5 that gets distributed with Mac OSX seems
      to leak. But I need to figure out where are the sources! I heard SF is not
      hosting the sources any more...
      
      
    2. login: "vasiljevic"
    3. mimetype: "text/plain"
    4. username: "vasiljevic"
  15. Ticket change [0bd16fb9cf] (rid 114060) by andreas_kupries on 2011-07-30 04:48:39:

    1. icomment:
      Thread sources.
      
      See http://core.tcl.tk/ in general,
      and http://core.tcl.tk/thread/timeline?y=ci
      specifically.
      
      Further http://wiki.tcl.tk/28127
      and  http://wiki.tcl.tk/28126
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  16. Ticket change [52fa5766a8] (rid 126406) by vasiljevic on 2011-07-30 04:51:54:

    1. icomment:
      Hey, thanks Andreas! I think I will need to do some reading and learning
      new stuff...
      
      Apropos reported leak... did you try 2.6.6 release? I saw I have already
      corrected some things related to tpool already...
      
      
      
      
    2. login: "vasiljevic"
    3. mimetype: "text/plain"
    4. username: "vasiljevic"
  17. Ticket change [7d7b619232] (rid 97246) by andreas_kupries on 2011-07-30 04:54:42:

    1. icomment:
      You have seen that Don Porter has RC for 2.6.7 up ?
      See tcl-core mailinglist.
      
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  18. Ticket change [ff93a88972] (rid 108774) by vasiljevic on 2011-07-30 04:58:09:

    1. icomment:
      yes. there are no significant core-code related changes there.
      if 2.6.6 does not leak, the 2.6.7 will not either. 
      
      
    2. login: "vasiljevic"
    3. mimetype: "text/plain"
    4. username: "vasiljevic"
  19. Ticket change [73c25f1357] (rid 105092) by andreas_kupries on 2011-07-30 04:59:55:

    1. icomment:
      Oh, the question about '... did you try 2.6.6 release' was for Christian ...
      
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  20. Ticket change [bbe4352a2f] (rid 129565) by hobbs on 2011-07-30 05:18:28:

    1. icomment:
      I am able to repro the leak on Windows with ActiveTcl 8.5.9.2 and 8.4.19.5 using Thread 2.6.7 (not final).
      
      
    2. login: "hobbs"
    3. mimetype: "text/plain"
    4. username: "hobbs"
  21. Ticket change [37425139b7] (rid 107242) by auriocus on 2011-07-30 12:35:00:

    1. icomment:
      I foun dthe leak originally witjin ActiveState 8.5.10.1 on Windows. I can reproduce it using Tcl8.6 HEAD:
      bin/tclsh8.6
      % info patchlevel
      8.6b1.2
      % package require Thread
      2.6.7
      % 
      
      This Tcl8.6 is 64bit, the leakage seems to be twice as fast as with the 32bit version. 
      
      
    2. login: "auriocus"
    3. mimetype: "text/plain"
    4. username: "auriocus"
  22. Add attachment "threadpool_leakdemo84_slow.tcl" [4606e2fe5b] (rid 99446) by auriocus on 2011-07-30 12:48:31.

  23. Ticket change [31bca0b368] (rid 93485) by auriocus on 2011-07-30 12:48:32:

    1. icomment:
      
      
      File Added - 419751: threadpool_leakdemo84_slow.tcl
      
      
      
    2. login: "auriocus"
    3. mimetype: "text/plain"
    4. username: "auriocus"
  24. Ticket change [de5ccca9bc] (rid 114834) by auriocus on 2011-07-30 12:50:35:

    1. icomment:
      If I change the tpool::wait command, which is supposed to give back the still running processes in the list, the leakage becomes a bit slower (I checked after a fixed number of iterations). See the attached demo script. Therefore the joblist leaks, but it's not the only leak in here.  
      
      
    2. login: "auriocus"
    3. mimetype: "text/plain"
    4. username: "auriocus"
  25. Ticket change [57ce9121af] (rid 117691) by techentin on 2012-11-27 00:40:29:

    1. icomment:
      I see the same memory leak with Tcl 8.5.13 and Thread 2.6.7 on Linux.
      
      It looks to me like the resource leak is related to the thread pool maintaining information on completed jobs.  
      
      I inserted periodic calls to tpool::wait and tpool::get inside the loop that posts work to the thread pool, and observed reduced memory growth.  (About half)  If I call tpool::get twice on the same job, I get "no such job," so I presume that it cleans up some resources.  But I don't see anything explicit in the API to discard results from completed jobs. 
      
      When I changed the post option from -nowait to -detached, the memory leak went away.
      
      
      Bob
      
      
    2. login: "techentin"
    3. mimetype: "text/plain"
    4. username: "techentin"
  26. Ticket change [136d6cb024] (rid 257774) by serhiy.storchaka on 2026-10-12 18:03:20:

    1. icomment:
      This was a Thread package issue, and it no longer reproduces: with the attached
      script, memory stays flat over 1 million jobs with Thread 2.8.12 (Tcl 8.6) and
      Thread 3.0.4 (Tcl 9.0).
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"
    4. resolution changed to: "Works For Me"
    5. status changed to: "Closed"
  27. Ticket change [0b3a965b89] (rid 259895) by serhiy.storchaka on 2026-10-22 17:19:24:

    1. closedate changed to: "2461326.2523258333"
    2. closer changed to: "serhiy.storchaka"
    3. login: "serhiy.storchaka"