Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: ca18e19ff4ea98b7d05b0b6bfd3e9537ebfcacb6
Ticket: 987512ffffffffffffffffffffffffffffffffff
mem-leak in thread::send -async
User & Date: nobody on 2004-07-20 08:11:10
Changes

  1. icomment:
    Logged In: NO 
    
    Just an observation... 385 bytes in $::Thread and 25,000 of 
    them on the async queue for that thread that's 9.2MB of 
    data sitting in the queue for your thread.  That's not TCL 
    leaking memory.  Tcl threads are cooperative and not 
    preemptive so none of those async requests are executed 
    until your [vwait].
    
    I tried two variations of the testcase and didn't observe any 
    memory leaking... Here they are.
    
    #1: throw a bunch of -async's and then release the thread 
    over and over.
    
    for {set x 0} {$x < 2500} {incr x} {
        set thid [thread::create {thread::wait}]
        for {set ni 0} {$ni < 100} {incr ni} {
            thread::send -async $thid $::Thread
        }
        thread::release $thid
    }
    puts "DONE"
    
    ---------------------------------------------------
    #2: throw -async's at the thread every 10 milliseconds so it 
    can execute as we go.
    
    set ::thid [thread::create {thread::wait}]
    set ::requests 25000
    proc issue {} {
        if {[incr ::requests -1] != 0} {
            if {($::requests % 1000) == 0} {
                puts $::requests
            }
            thread::send -async $::thid $::Thread
            after 10 [namespace code issue]
        } else {
            puts "DONE"
        }
    }
    issue
    thread::wait
    
    
  2. login: "nobody"
  3. mimetype: "text/plain"
  4. username: "nobody"