Skip to content
Tcl Source Code History Of Ticket 5888e0e1018d10cb
Login

History Of Ticket 5888e0e1018d10cb

Artifacts Associated With Ticket 5888e0e1018d10cb

  1. Ticket change [9772f83c48] (rid 251382) by wmrieker on 2026-02-07 12:38:59:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-plain"
    4. comment initialized to:
      Running the attached script, it goes slower and slower.  And it grows in size.
      
      I am running it on Linux Ubuntu 22.
      
    5. foundin initialized to: "9.0.3"
    6. is_private initialized to: "0"
    7. login: "wmrieker"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "b7fa0016342485e5707500a3b8f91f8f1de8bfb2"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "wmrieker"
    14. subsystem initialized to: "41. Memory Allocation"
    15. title initialized to: "memory leak"
    16. type initialized to: "Bug"
  2. Ticket change [76d3f88e29] (rid 251383) by wmrieker on 2026-02-07 12:40:57:

    1. icomment:
      set randseed 123456789
      
      for {set i 0} true {incr i} {
      
          set randval 0
          for {set j 0} {$j < 12} {incr j} {
              set xnor [expr {~ (($randseed >> 31) ^ ($randseed >> 30) ^ ($randseed >> 28) ^ ($randseed >> 27))}]
              set randseed [expr {($randseed << 1) | ($xnor & 1)}]
              set randval [expr {($randval << 1) | ($randseed & 1)}]
          }
      
          set r $randval
          if {$i % 1024 == 0} {
              set f [open /proc/self/status r]
              set s ""
              while {[gets $f l] >= 0} {
                  if {[string range $l 0 6] == "VmSize:"} {
                      set s $l
                      break
                  }
              }
              close $f
              set t [clock seconds]
              puts [format "%02d:%02d:%02d  %12d  %04o %s" [expr {$t / 3600 % 24}] [expr {$t / 60 % 60}] [expr {$t % 60}] $i $r $s]
          }
      }
      
    2. login: "wmrieker"
    3. mimetype: "text/plain"
  3. Ticket change [1b50e24570] (rid 251384) by oehhar on 2026-02-07 12:41:13:

    1. icomment:
      Sorry, there is no attachement...
      Harald
      
    2. login: "oehhar"
    3. mimetype: "text/plain"
  4. Ticket change [fa52f8f9cb] (rid 251385) by pointsman on 2026-02-07 13:30:52:

    1. icomment:
      The value of the variable randseed is constantly growing - after a few thousand
      runs of the outer loop it already has a length of a few ten thousand digits.
      
      Given this the growing runtime and memory allocation is basically expected.
      
      At least in the given form the script doesn't clearly show there is memory lost.
      
    2. login: "pointsman"
    3. mimetype: "text/plain"
  5. Ticket change [c7ef5416b6] (rid 251386) by sebres on 2026-02-07 14:47:40:

    1. closedate changed to: "2461079.11643613"
    2. closer changed to: "sebres"
    3. icomment:
      Yes, the analyse of Rolf is pretty correct - the (bignum) value of <code>randseed</code> grows endless by 2<sup>i</sup> with each iteration, so the bignum math becomes slower as well as the memory reserved for this "integer" grows.
      
      I suspect it's missing something like a constant constraint (truncation to wide-int or int):
      <code><pre>
       set randval 0
       for {set j 0} {$j < 12} {incr j} {
         set xnor [expr {~ (($randseed >> 31) ^ ($randseed >> 30) ^ ($randseed >> 28) ^ ($randseed >> 27))}]
      <b style="color:red">-  set randseed [expr {($randseed << 1) | ($xnor & 1)}]</b>
      <b style="color:green">+  set randseed [expr {($randseed << 1) & 0x7fffffffffffffff | ($xnor & 1)}]</b>
         set randval [expr {($randval << 1) | ($randseed & 1)}]
       }
      </pre></code>
      
      Thus it is clearly not a memleak or performance degradation, ticket is closed as incorrect.
      
    4. login: "sebres"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Invalid"
    7. status changed to: "Closed"