Artifacts Associated With Ticket 218066
Ticket change [1a93e6493e] (rid 123004) by nobody on 2000-10-26 00:52:48:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
OriginalBugID: 1557 RFE Version: 8.0.4 SubmitDate: '1999-03-19' LastModified: '2000-04-03' Severity: LOW Status: Closed Submitter: pat ChangedBy: hobbs OS: Other OSVersion: NT4.0, IRIX 6.2, IRIX 6.5, Mac OS8.1 & OS8.5 Machine: NA FixedDate: '2000-10-25' ClosedDate: '2000-04-03' Name: William Chen DesiredBehavior: It appears that the garbage collection properties of Tcl+Tk does not extend to the "infinitely Recursive" calls. Placing the recursive function call in an after script script is still recursion. Memory has to be released by unsetting unused local variables. Unless this local memory is released, it will never be released while the Wish Shell is running. I'm providing samples of two methods used to create event handlers. The after command allows the separate polling event handlers to execute in different threads. It is also more elegant than putting them all into one big while loop since multiple events can be polled at different intervals. Unset is only briefly mentioned on your web page. Ousterhout's _Tcl_and_the_Tk_ToolKit_ and Welch's _Practical_Programming_in_Tcl_and_Tk_ books dedicate 1 small paragraph each to unset. ______________________________ Function1 {} { global Function1ID Fucntion2 set Function1ID [after _time_ Function1] } Function2 {} { global saveString local var1 var2 string1 set var1 Somevalue set var2 Somevalue set string1 SomeLargevalueReturnedFromFunctionCall set saveString $string1 ;# copy local value to global #Local variables must be unset to release memory for recursive call #Normally Garbage Collection will take care of this. #We were not doing this before and it was causing memory leaks unset var1 unset var2 unset string1 } KillFunciton1 {} { after cancel $Function1ID } _________________________________ TestFunction {} { global TestFuntionID global saveString local var1 var2 sting1 set var1 SomeValue set var2 SomeValue set string1 SomeLargeValueRetunedFromFunctionCall set saveString $string1 ;# copy local value to global #Local variables must be unset to release memory for recursive call unset var1 unset var2 unset string1 #Make a recursive call to the function after a set time. set TestFunctionID after _time_ TestFunction } KillTestFunction {} { after cancel $TestFunctionID } After calling KillTestFunction or KillFunction1, TestFuntion and Funtion1 does not know that the recursive call has been interrupted. The memory created withing these functions does not get released without an explicit call to unset them. "local" isn't a Tcl core command, and it may not be coded correctly to release the objects. Otherwise, this doesn't seem like it should be a problem in the core (Tcl tests Pure). -- 04/03/2000 hobbs - foundin initialized to: "obsolete: 8.0.4"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "69. Other"
- title initialized to:
The necessary use of the 'unset' in a recursive call is not
- type initialized to: "Bug"
Ticket change [64a7454877] (rid 92803) by welch on 2000-10-26 08:13:45:
- closedate changed to: "2000-10-26T01:13:45"
- closer changed to: "welch"
- priority changed to: "2"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [598013e3cc] (rid 117988) by dgp on 2001-04-16 23:39:04:
- closedate changed to: "2001-04-16T16:39:04"
- closer changed to: "dgp"
- resolution changed to: "Invalid"
- subsystem changed to: "None"