Artifacts Associated With Ticket 5888e0e1018d10cb
Ticket change [9772f83c48] (rid 251382) by wmrieker on 2026-02-07 12:38:59:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-plain"
- 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.
- foundin initialized to: "9.0.3"
- is_private initialized to: "0"
- login: "wmrieker"
- priority initialized to: "5 Medium"
- private_contact initialized to: "b7fa0016342485e5707500a3b8f91f8f1de8bfb2"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "wmrieker"
- subsystem initialized to: "41. Memory Allocation"
- title initialized to: "memory leak"
- type initialized to: "Bug"
Ticket change [76d3f88e29] (rid 251383) by wmrieker on 2026-02-07 12:40:57:
- 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] } } - login: "wmrieker"
- mimetype: "text/plain"
- icomment:
Ticket change [1b50e24570] (rid 251384) by oehhar on 2026-02-07 12:41:13:
- icomment:
Sorry, there is no attachement... Harald
- login: "oehhar"
- mimetype: "text/plain"
- icomment:
Ticket change [fa52f8f9cb] (rid 251385) by pointsman on 2026-02-07 13:30:52:
- 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.
- login: "pointsman"
- mimetype: "text/plain"
- icomment:
Ticket change [c7ef5416b6] (rid 251386) by sebres on 2026-02-07 14:47:40:
- closedate changed to: "2461079.11643613"
- closer changed to: "sebres"
- 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. - login: "sebres"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Invalid"
- status changed to: "Closed"