Anatoly Torchinskiy schrieb am Donnerstag, 30. November 2023 um 04:33:37 UTC+1:
I have code that is leaking, I been trying to figure out what I am doing wrong. I created a test example and I am about to reproduce in tclsh
set holder {}
for {set i 0} {$i < 1144195} {incr i} {
set attr [dict create]
set all_keys {"X" "P" "A" "B" "T" "Y" "E" "W" "B"}
foreach key $all_keys {
dict set attr $key [expr int(rand()*20)]
}
lappend holder $attr
}
This eats ~2GB of RAM, using Tcl 8.5. If I then do set holder {} , after which in my head would release the holder object and all of its things, instead I see Tcl still using that ram and not letting go. What am I doing wrong here? I have similar
example I did in Python and the moment I set holder in Python to None, everything is freed, but in Tcl I cant see to actually get my memory back.
I am on mac btw, not sure if this would do anything.
Thanks,
Anatoly
Afaik tcl is maintaining an own list of used memory and will reuse it.
Just put your code in a proc and run it. The holder var is then local and will be deleted at the end of the proc.
The memory will grow in the first call and then stay nearly the same in further calls.
HTH
rene
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)