Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 056ea5022207e63ff8f5a2fe091562d663dcd935
Ticket: 3493120fffffffffffffffffffffffffffffffff
Thread extension, memory leak after thread exit
User & Date: sebres on 2012-02-24 13:33:32
Changes

  1. assignee changed to: "andreas_kupries"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Version: 8.5.11 (original and current core-8-5-branch)
    Platform: Windows (linux not yet tested)
    
    After exiting of threads, they leave a memory leak. 
    Consequence of that: we cannot use techniques such as 'idletime' (to release some system resources, for example large tcl codes are no more used, etc, etc.).
    
    After run of following script I have lost 100MB of memory. In fact, nothing will be done here, except threads are created and exited.
    
    Test script:
    
    # for test purposes - to wait for threads exited :
    tsv::set testth count 0
    # this create once a thread pool, and generate jobs :
    proc test {} {
      # create a thread pool if not yet already exists :
      if {![llength [tpool::names]]} {
        tpool::create -minworkers 0 -maxworkers 5 -idletime 1 -initcmd {
          # + 1 thread
          tsv::set testth count [expr {[tsv::get testth count] + 1}]; puts [thread::id]init!!!!!
        } -exitcmd {
          # - 1 thread
          tsv::set testth count [expr {[tsv::get testth count] - 1}]; puts [thread::id]!!!!!exit
        }
      }
     # generate jobs until 5 threads are created :
      while {[tsv::get testth count] < 5} {
        tpool::post -detached -nowait [lindex [tpool::names] 0] {
          puts [thread::id]!!job; tsv::array unset testthcount [thread::id]
        }
        update
      }
    }
    # repeat test 100 times, in addition waiting for the 
    # threads to be finished each iteration :
    time {test; while {[tsv::get testth count]} {after 10};} 100
    
    
  4. foundin changed to: "obsolete: 8.5.11"
  5. is_private changed to: "0"
  6. priority changed to: "7 High"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "sebres"
  10. subsystem changed to: "49. Threading"
  11. title changed to: "Thread extension, memory leak after threa exit"
  12. type changed to: "Bug"