Skip to content
Tcl Source Code History Of Ticket 219213ffffffffff
Login

History Of Ticket 219213ffffffffff

Artifacts Associated With Ticket 219213ffffffffff

  1. Ticket change [d13c75859e] (rid 113315) by nobody on 2000-10-26 05:03:39:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized 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 initialized to: "obsolete: 8.2.2"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "07. Variables"
    10. title initialized to: "Memory leak in "info exists array()""
    11. type initialized to: "Bug"
  2. Ticket change [423c4d9890] (rid 116336) by hobbs on 2000-11-02 04:16:54:

    1. closedate changed to: "2000-11-01T21:16:54"
    2. closer changed to: "hobbs"
    3. foundin changed to: "obsolete: 8.4a2"
    4. icomment:
      Patch from Mark Patton fixes this problem (put in 8.4a2):
      
      jupiter [~/cvs/tcl8.4] 191 % cvs diff -bc generic/tclVar.c 
      Index: generic/tclVar.c
      ===================================================================
      RCS file: /home/cvs/external/tcl/generic/tclVar.c,v
      retrieving revision 1.23
      diff -b -c -r1.23 tclVar.c
      *** tclVar.c    2000/08/25 20:39:31     1.23
      --- tclVar.c    2000/11/01 21:16:47
      ***************
      *** 4863,4869 ****
        {
            Var *varPtr;
            Var *arrayPtr;
      -     char *msg;
        
            /*
             * The choice of "create" flag values is delicate here, and
      --- 4863,4868 ----
      ***************
      *** 4876,4892 ****
             */
        
            varPtr = TclLookupVar(interp, varName, (char *) NULL,
      !             0, "access",
      !             /*createPart1*/ 0, /*createPart2*/ 1, &arrayPtr);
            if (varPtr == NULL) {
              return NULL;
            }
      !     if ((varPtr != NULL) &&
      !           ((varPtr->tracePtr != NULL)
      !           || ((arrayPtr != NULL) && (arrayPtr->tracePtr != NULL)))) {
      !       msg = CallTraces((Interp *)interp, arrayPtr, varPtr, varName,
                      (char *) NULL, TCL_TRACE_READS);
      !       if (msg != NULL) {
                  /*
                   * If the variable doesn't exist anymore and no-one's using
                   * it, then free up the relevant structures and hash table entries.
      --- 4875,4892 ----
             */
        
            varPtr = TclLookupVar(interp, varName, (char *) NULL,
      !             0, "access", /*createPart1*/ 0, /*createPart2*/ 1, &arrayPtr);
      ! 
            if (varPtr == NULL) {
              return NULL;
            }
      ! 
      !     if ((varPtr->tracePtr != NULL)
      !           || ((arrayPtr != NULL) && (arrayPtr->tracePtr != NULL))) {
      !       CallTraces((Interp *)interp, arrayPtr, varPtr, varName,
                      (char *) NULL, TCL_TRACE_READS);
      !     }
      ! 
            /*
             * If the variable doesn't exist anymore and no-one's using
             * it, then free up the relevant structures and hash table entries.
      ***************
      *** 4894,4902 ****
        
                  if (TclIsVarUndefined(varPtr)) {
                      CleanupVar(varPtr, arrayPtr);
      -           }
                  return NULL;
      -       }
            }
            return varPtr;
        }
      --- 4894,4901 ----
        
            if (TclIsVarUndefined(varPtr)) {
              CleanupVar(varPtr, arrayPtr);
              return NULL;
            }
      + 
            return varPtr;
        }
      
      
      
    5. login: "hobbs"
    6. mimetype: "text/plain"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"
    9. username: "hobbs"