Artifacts Associated With Ticket 219213
Ticket change [d13c75859e] (rid 113315) by nobody on 2000-10-26 05:03:39:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
OriginalBugID: 3851 Bug Version: 8.2.2 SubmitDate: '1999-12-10' LastModified: '1999-12-11' Severity: MED Status: Assigned Submitter: techsupp ChangedBy: hobbs OS: All FixedDate: '2000-10-25' ClosedDate: '2000-10-25' Name: Edwin Diekemper ReproducibleScript: % proc testleak {} { set foo(1) one set foo(2) two for { set idx 0 } { $idx < 200000 } { incr idx } { info exists foo($idx) } } % testleak ObservedBehavior: The size of the process gets very large. $ ps -p 6804 PID TTY TIME COMD 6804 pts/20 0:05 tclsh Before running testleak: $ ls -l /proc/6804 -rw------- 1 user banknet 1622016 Dec 10 14:07 /proc/6804 After running testleak: $ ls -l /proc/6804 -rw------- 1 user banknet 15613952 Dec 10 14:07 /proc/6804 DesiredBehavior: Very little change in the size of the process. I've verified that the growth occurs, but when I run this through purify, it doesn't complain about any memory leaks. It only occurs when the array variable on which you are doing 'info exists' already occurs. -- 12/10/1999 hobbs Found the problem. Each time you do 'info exists' on a known array, it will create the hash entry for the key item if it didn't already exist. This will occur just once for each key, but when you just want to know it exists, that's bad. If you were to set the var following, then it wouldn't take any more mem (except for the length of the value), so you only reach the extreme case of waste in the example above. The comments in the code justifying this were to use existing C functions and maintain compatibility with 7.6 behavior. It looks like the internal C funcs have to be rewritten to prevent this quasi-leak (really a mem waste, no leak). -- 12/11/1999 hobbs - foundin initialized to: "obsolete: 8.2.2"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "07. Variables"
- title initialized to: "Memory leak in "info exists array()""
- type initialized to: "Bug"
Ticket change [423c4d9890] (rid 116336) by hobbs on 2000-11-02 04:16:54:
- closedate changed to: "2000-11-01T21:16:54"
- closer changed to: "hobbs"
- foundin changed to: "obsolete: 8.4a2"
- icomment:
Patch from Mark Patton fixes this problem (put in 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: "Fixed"
- status changed to: "Closed"
- username: "hobbs"