memory leak
Closed / Invalid1804709fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2007-09-29 12:22:07
Tcl 8.4.* (8.4.16 for example), Win2000
After this script
#################################
for {set i 1} {$i<=1000000} {incr i} {
lappend lst [string repeat * 40]
}
unset lst
#################################
windows tasks manager shows ~90Mb of memory usage.
Another script:
set str [string repeat * 40]
##############################################
for {set i 1} {$i<=1000000} {incr i} {
lappend lst $str
}
unset lst
##############################################
- no problem.
A have a lot of problems in my proframs that deal with textual files. After leaving of procedures - a lot of memory remains captured which must be freed.
dkfplain2007-09-30 06:40:33
Logged In: YES user_id=79902 Originator: NO This is not a bug: this is exactly how things are designed to work. In the second case (behind the scenes) each value in the list is actually read-only shared with all the others, but in the first case each of the members is not shared since the Tcl implementation is not smart enough to figure out that [string repeat] can be shared when the inputs are identical. Making it smart enough is a lot of work for arguably an uncommon case, so we don't. :-) The memory is only not returned to the OS because Tcl uses a high-water-mark allocator. You can tell it is not a "real leak" because if you run the "leaky" code again (including the [unset]), the memory requirements remain the same.
dkf Closed ticket [1804709fff].
[History diff]2007-09-30 06:40:34
Log in (anonymous is fine) to add a comment.