Skip to content
Tcl Source Code History Of Ticket 2874678fffffffffffffffffffffffffffffffff
Login

History Of Ticket 2874678fffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 2874678fffffffffffffffffffffffffffffffff

  1. Ticket change [66a7c28320] (rid 102751) by wastl-nagel on 2009-10-08 12:35:15:

    1. assignee initialized to: "dkf"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      If a dict is created and filled via "dict incr" with a bigger set of keys it seems to leak. If the dict is destroyed (unset or overwritten) a lot of memory still keeps allocated. 
      
      The following code consumes approx. 500MB memory on my machine (Linux, 64-bit):
      
      set chars {a b c d e f g h i j k l m n o p q r s t u v w x y z
      A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
      0 1 2 3 4 5 6 7 8 9}
      
      for {set i 0} {$i < 1000} {incr i} {
      append prefix [lindex $chars [expr int([tcl::mathfunc::rand]*62)]]
      set dictionary [dict create]
      foreach char $chars {
      foreach c $chars {
      dict incr dictionary $prefix$char$c $i
      }
      }
      }
      
      I've tested Tcl 8.5.2 (OpenSuSE 11.0, x86_64), 8.5.7, 8.6b1 (both built from source), 
      all three leak, cf. attached valgrind log files for same code but only 100 cycles.
      
      For 8.5.2 TclBN_mp_init_size according to valgrind seems to be reason.
      
      % uname -mrvs
      Linux 2.6.25.20-0.5-default #1 SMP 2009-08-14 01:48:11 +0200 x86_64
      
    4. foundin initialized to: "obsolete: 8.5.7"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "wastl-nagel"
    10. subsystem initialized to: "15. Dict Object"
    11. title initialized to: "dict incr leaks"
    12. type initialized to: "Bug"
  2. Add attachment "valgrind_tcl_dict.zip" [52400f243b] (rid 126283) by wastl-nagel on 2009-10-08 19:35:19.

  3. Ticket change [e9f7279d17] (rid 104897) by wastl-nagel on 2009-10-08 19:35:20:

    1. icomment:
      
      
      File Added - 345735: valgrind_tcl_dict.zip
      
      
      
    2. login: "wastl-nagel"
    3. mimetype: "text/plain"
    4. username: "wastl-nagel"
  4. Ticket change [20a6be83c4] (rid 130462) by wastl-nagel on 2009-10-08 20:26:03:

    1. icomment:
      May the patch below fix the problem?
      
      --- ./generic/tclDictObj.c~     2009-01-06 17:07:17.000000000 +0100
      +++ ./generic/tclDictObj.c      2009-10-08 15:00:29.000000000 +0200
      @@ -2148,6 +2148,7 @@
                  mp_int increment;
      
                  code = Tcl_GetBignumFromObj(interp, objv[3], &increment);
      +            mp_clear(&increment);
                  if (code != TCL_OK) {
                      Tcl_AddErrorInfo(interp, "\n    (reading increment)");
                  } else {
      
      
      
    2. login: "wastl-nagel"
    3. mimetype: "text/plain"
    4. username: "wastl-nagel"
  5. Ticket change [c3578bf654] (rid 111642) by dkf on 2009-10-08 21:10:09:

    1. priority changed to: "9 Immediate"
  6. Ticket change [2b27f14a1b] (rid 118687) by dkf on 2009-10-08 21:21:09:

    1. icomment:
      Leaks 8 words per *interpreted* [dict incr] that creates a dictionary entry.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  7. Ticket change [228bd34531] (rid 130766) by dkf on 2009-10-08 21:22:24:

    1. icomment:
      And requires an explicit increment to do so.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  8. Ticket change [b831f19bae] (rid 128932) by dkf on 2009-10-08 21:24:57:

    1. icomment:
      The following test seems to be exact:
      
      test dict-19.3 {dict: testing for leaks - Bug 2874678} -setup {
          proc memtest script {
      set end [lindex [split [memory info] \n] 3 3]
      for {set i 0} {$i < 5} {incr i} {
          uplevel 1 $script
          set tmp $end
          set end [lindex [split [memory info] \n] 3 3]
      }
      expr {$end - $tmp}
          }
      } -constraints memory -body {
          set d aDictVar; # Force interpreted [dict incr]
          memtest {
      dict incr $d aKey 0
      unset $d
          }
      } -cleanup {
          unset d
          rename memtest {}
      } -result 0
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  9. Ticket change [6726aadc0a] (rid 102854) by dkf on 2009-10-08 21:44:11:

    1. icomment:
      Fixed in HEAD and 8.5 (the patch was slightly wrong, but helped narrow down what needed to be done a lot; thanks!)
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  10. Ticket change [a724b11707] (rid 98732) by dkf on 2009-10-08 21:44:12:

    1. closedate changed to: "2009-10-08T14:44:12"
    2. closer changed to: "dkf"
    3. icomment:
      
      
      allow_comments - 1
      
      
      
    4. login: "dkf"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "dkf"