Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: d13c75859e5dadb2a7f3e5cf52186a539daec6e1
Ticket: 219213ffffffffffffffffffffffffffffffffff
Memory leak in "info exists array()"
User & Date: nobody on 2000-10-26 05:03:39
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 3851 Bug
    Version: 8.2.2
    SubmitDate: '1999-12-10'
    LastModified: '1999-12-11'
    Severity: MED
    Status: Assigned
    Submitter: techsupp
    ChangedBy: hobbs
    OS: All
    FixedDate: '2000-10-25'
    ClosedDate: '2000-10-25'
    
    
    Name: Edwin Diekemper
    
    ReproducibleScript:
    % proc testleak {} {
    set foo(1) one
    set foo(2) two
    for { set idx 0 } { $idx < 200000 } { incr idx } {
    info exists foo($idx)
    }
    }
    % testleak
    
    ObservedBehavior:
    The size of the process gets very large.
    $ ps -p 6804
       PID TTY      TIME COMD
      6804 pts/20   0:05 tclsh
    Before running testleak:
    $ ls -l /proc/6804 
    -rw-------   1 user  banknet  1622016 Dec 10 14:07 /proc/6804
    After running testleak:
    $ ls -l /proc/6804
    -rw-------   1 user  banknet  15613952 Dec 10 14:07 /proc/6804
    
    DesiredBehavior:
    Very little change in the size of the process.
    
    
    
    I've verified that the growth occurs, but when I run this through
    purify, it doesn't complain about any memory leaks.
    It only occurs when the array variable on which you are
    doing 'info exists' already occurs. 
    -- 12/10/1999 hobbs
    Found the problem.  Each time you do 'info exists' on a known
    array, it will create the hash entry for the key item if it
    didn't already exist.  This will occur just once for each key,
    but when you just want to know it exists, that's bad.  If you
    were to set the var following, then it wouldn't take any more
    mem (except for the length of the value), so you only reach
    the extreme case of waste in the example above.
    
    The comments in the code justifying this were to use existing
    C functions and maintain compatibility with 7.6 behavior.  It
    looks like the internal C funcs have to be rewritten to prevent
    this quasi-leak (really a mem waste, no leak). 
    -- 12/11/1999 hobbs
    
  4. foundin changed to: "obsolete: 8.2.2"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "07. Variables"
  10. title changed to: "Memory leak in "info exists array()""
  11. type changed to: "Bug"