Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 64708928c7c4bdd0be87c182d6990aca409b8705
Ticket: 1706058fffffffffffffffffffffffffffffffff
Possible Memory Leak (with Threads?)
User & Date: rkeene on 2007-04-23 18:14:10
Changes

  1. assignee changed to: "hobbs"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    #! /home/rkeene/devel/spamgateway/work/tcl8.4.14/INST/bin/tclsh8.4
    # This seems to leak memory if I do:
    #    for i in `seq 1 3000`; do telnet localhost 8931 & done
    # The more times I run the above loop, the larger the "RES" section for the process under "top" becomes.
    
    package require Thread 2.6.5
    
    set workers_idx 0
    for {set i 0} {$i < 20} {incr i} {
    lappend workers [thread::create {
    proc HandleConnection_worker {sock addr port} {
    close $sock
    }
    
    thread::wait
    }]
    }
    
    proc HandleConnection {sock addr port} {
    after idle [list _HandleConnection $sock $addr $port]
    }
    
    proc _HandleConnection {sock addr port} {
    set tid [lindex $::workers $::workers_idx]
    
    set ::workers_idx [expr ($::workers_idx + 1) % [llength $::workers]]
    
    thread::transfer $tid $sock
    thread::send -async $tid [list HandleConnection_worker $sock $addr $port]
    }
    
    socket -server HandleConnection 8931
    
    thread::wait
    
  4. foundin changed to: "None"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "rkeene"
  10. subsystem changed to: "41. Memory Allocation"
  11. title changed to: "Possible Memory Leak (with Threads?)"
  12. type changed to: "Bug"