Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2002-10-11
05:06 • Closed ticket [617588ffff]: memory leak plus 7 other changes artifact: 989993bad6 user: hobbs
2002-10-02
14:48 • New ticket [617588ffff]. artifact: 1e77b13af5 user: karel_janacek

memory leak

Closed / Invalid617588ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 24 years ago
Descriptionplain2002-10-02 14:48:03
Hello,
I am afraid, we found a memory leak bug.
We use Linux RH 7.1, Tcl 8.4.0 (8.3.3).

When we run the test script

#!/bin/sh
#test \
exec wish8.4 "$0" "$@"
wm iconify .

global q
array set ::q {}

bell
after 5000
for {set i 0} {$i < 100000} {incr i} {
set ::q($i) $i
}
bell
after 5000
array unset ::q
bell
after 5000
exit


and inspect the memory using the command "ps xv|grep 
wish" after each bell
(not by TCL_MEM_DEBUG), it looks that memory is not 
deallocated by array unset.
                                          VSZ  RSS
 3901 pts/0    S      0:00    731     2  4689 2752  1.4 
wish8.4 ./test.tcl
 3901 pts/0    S      0:01    731     2 15821 13896  7.2 
wish8.4 ./test.tcl
 3901 pts/0    S      0:02    731     2 15561 13636  7.1 
wish8.4 ./test.tcl

When we change the script (variable -> constant)
for {set i 0} {$i < 100000} {incr i} {
set ::q($i) 1
}
or (variable -> another variable with constant value)
set j 1
for {set i 0} {$i < 100000} {incr i} {
set ::q($i) $j
}
it looks ok.
                                          VSZ  RSS
 3914 pts/0    S      0:00    731     2  4689 2752  1.4 
wish8.4 ./test.tcl
 3914 pts/0    S      0:01    731     2 11909 9984  5.2 
wish8.4 ./test.tcl
 3914 pts/0    S      0:01    731     2  4689 2764  1.4 
wish8.4 ./test.tcl

Next, when we use
.. [array get ::q]
memory is not deallocated too.

Sorry fo my english. Best regards.
Karel Janacek
hobbsplain2002-10-11 05:06:44
Logged In: YES 
user_id=72656

This is not a memory leak.  Tcl maintains a high-water mark 
object allocator by default.  Your script is allocating 100,000 
different objects, which won't be freed completely to the 
system.  They will instead be reused.  You can check google 
for more in-depth info on this.
Log in (anonymous is fine) to add a comment.