Artifacts Associated With Ticket 219597ffffffffff
Ticket change [3b6091586a] (rid 112733) by msp on 2000-10-28 01:53:46:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
I've noticed some strange memory leaks using info exists on arrays.The leak is also present in 8.3.1. I'm running Tcl on Linux. The below scripts demonstrate the memory leak. # this leaks big time proc main {argv} { expr {srand([clock clicks])} for {set i 0} {$i < 1000} {incr i} { set n1 [expr {int(rand() * 1000)}] set n2 [expr {int(rand() * 1000)}] set x($n1,$n2) 0 } while {1} { set n1 [expr {int(rand() * 1000)}] set n2 [expr {int(rand() * 1000)}] if {[info exists x($n1,$n2)]} { incr x($n1,$n2) } } } # no leak proc main2 {argv} { expr {srand([clock clicks])} for {set i 0} {$i < 1000} {incr i} { set n1 [expr {int(rand() * 1000)}] set n2 [expr {int(rand() * 1000)}] set x($n1,$n2) 0 } while {1} { set n1 [expr {int(rand() * 1000)}] set n2 [expr {int(rand() * 1000)}] catch { incr x($n1,$n2) } } } # no leak proc main3 {argv} { expr {srand([clock clicks])} for {set i 0} {$i < 1000} {incr i} { set n1 [expr {int(rand() * 1000)}] set x($n1) 0 } while {1} { set n1 [expr {int(rand() * 1000)}] if {[info exists x($n1)]} { incr x($n1) } } } - foundin initialized to: "obsolete: 8.4a1"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "msp"
- subsystem initialized to: "07. Variables"
- title initialized to: "Memory leak with info exists and arrays"
- type initialized to: "Bug"
Ticket change [7cc84af0ee] (rid 97136) by hobbs on 2000-11-02 04:18:24:
- closedate changed to: "2000-11-01T21:18:24"
- closer changed to: "hobbs"
- icomment:
Dup of 119213, fixed for 8.4a2. jupiter [~/cvs/tcl8.4] 191 % cvs diff -bc generic/tclVar.c Index: generic/tclVar.c =================================================================== RCS file: /home/cvs/external/tcl/generic/tclVar.c,v retrieving revision 1.23 diff -b -c -r1.23 tclVar.c *** tclVar.c 2000/08/25 20:39:31 1.23 --- tclVar.c 2000/11/01 21:16:47 *************** *** 4863,4869 **** { Var *varPtr; Var *arrayPtr; - char *msg; /* * The choice of "create" flag values is delicate here, and --- 4863,4868 ---- *************** *** 4876,4892 **** */ varPtr = TclLookupVar(interp, varName, (char *) NULL, ! 0, "access", ! /*createPart1*/ 0, /*createPart2*/ 1, &arrayPtr); if (varPtr == NULL) { return NULL; } ! if ((varPtr != NULL) && ! ((varPtr->tracePtr != NULL) ! || ((arrayPtr != NULL) && (arrayPtr->tracePtr != NULL)))) { ! msg = CallTraces((Interp *)interp, arrayPtr, varPtr, varName, (char *) NULL, TCL_TRACE_READS); ! if (msg != NULL) { /* * If the variable doesn't exist anymore and no-one's using * it, then free up the relevant structures and hash table entries. --- 4875,4892 ---- */ varPtr = TclLookupVar(interp, varName, (char *) NULL, ! 0, "access", /*createPart1*/ 0, /*createPart2*/ 1, &arrayPtr); ! if (varPtr == NULL) { return NULL; } ! ! if ((varPtr->tracePtr != NULL) ! || ((arrayPtr != NULL) && (arrayPtr->tracePtr != NULL))) { ! CallTraces((Interp *)interp, arrayPtr, varPtr, varName, (char *) NULL, TCL_TRACE_READS); ! } ! /* * If the variable doesn't exist anymore and no-one's using * it, then free up the relevant structures and hash table entries. *************** *** 4894,4902 **** if (TclIsVarUndefined(varPtr)) { CleanupVar(varPtr, arrayPtr); - } return NULL; - } } return varPtr; } --- 4894,4901 ---- if (TclIsVarUndefined(varPtr)) { CleanupVar(varPtr, arrayPtr); return NULL; } + return varPtr; } - login: "hobbs"
- mimetype: "text/plain"
- resolution changed to: "Duplicate"
- status changed to: "Closed"
- username: "hobbs"