Richard Suchenwirth 2007-10-09 Why does Tcl leak memory? As explained on that page, Tk_Uids are created for text and canvas tags and never released. In a long running process, which on a canvas displays images and bounding boxes (polygons), I saw memory rise from 65MB to over 400 MB after some hours. Fixes as suggested by dkf:
$c create image 0 0 -image $im -anchor nw ... $c delete all
but create and display the image once, and reconfigure it with
$im copy $im2 -shrink
if {![info exists g(of$n)]} { set id [$w create poly $coords -fill {} -outline $color -tag "xx of$n"] set g(of$n) $id } else { set id $g(of$n) $w coords $id $coords $w itemconfigure $id -outline $color $w raise $id }
and instead of deleting them, just move them "out of sight"
foreach i [$w find withtag xx] {$w coords $i -100 -100 -99 -99}