#5006 Thread extension, memory leak after thread exit

obsolete: 8.5.11
open
7
2012-02-25
2012-02-24
No

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

Discussion

  • Serg G. Brester

    Serg G. Brester - 2012-02-24
    • summary: Thread extension, memory leak after threa exit --> Thread extension, memory leak after thread exit
     
  • Serg G. Brester

    Serg G. Brester - 2012-02-24

    tested with thread2.6.5, thread2.6.7 and current thread-2-7-branch

     
  • Kevin B KENNY

    Kevin B KENNY - 2012-02-25
    • labels: 104253 --> 80. Thread Package
     
  • Serg G. Brester

    Serg G. Brester - 2012-02-28

    It seems to be a problem with tcl core (threaded memory subsystem etc.) - I made a test without thread.dll, where I create threads with WinAPI, call inits and hereafter finalize - leak remains.

    Following singlethreaded script runs without leak also:

    time {
    try {
    set ntp [interp create]
    $ntp eval "load thread27"
    } finally {
    interp delete $ntp
    }
    } 500

     
  • Serg G. Brester

    Serg G. Brester - 2012-02-28

    much short variant of leak test :

    puts [thread::names]
    time {
    thread::create {::thread::release}
    } 500
    puts [thread::names]

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks