Artifacts Associated With Ticket 229969ffffffffff
Ticket change [af970e2811] (rid 97841) by nobody on 2001-01-24 21:36:26:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
I am creating a interpreter in a C++ program using the call Tcl_CreateInterp after that I use Tcl_SetVar to define variable values and then call Tcl_EvalFile to evaluate a script . The code that is running the interpreter is running in its own thread and I use Tcl_GetVar and Tcl_SetVar to communicate with the interpreter from another thread. All works great but when I delete the interpeter with Tcl_DeleteInterp I find a memory leak of about 10 k due to Tcl_Alloc (using Solaris Workshop Leak Check). According to My latest TCL/TK book (Welch) calling Tcl_DeleteInterp only marks the interpreter as deleteable and only deletes if Tcl_Release is called as Many Times as Tcl_Preserve. I modified the Tcl Code to emit a message to stdout when Tcl_Preserve is called. At no time is the message seen unless I specifically call it in my C++ program. I have called Tcl_UnsetVar on all my global variable prior to deletion and it has no effect. All my variables are set with the option TCL_GLOBAL_ONLY flag. 1 ) if the call Tcl_DeleteInterp marks the interpreter as deletable and then returns how is the deletion code ever going to run ? 2) If Tcl_DeleteInterp does indeed try to remove all memory before returning then you have a memory leak problem. 3) If you don't think you have a memory leak problem then given the information above how do I free the variables I Set and Get. What concerns me is that Tcl reassigns the memory that a variable possesses every time it is set. Do I have to free that memory first before setting (i.e char * data = Tcl_GetVar(interp,"data",TCL_GLOBAL_ONLY); Tcl_Free(data); ?
- foundin initialized to: "obsolete: 8.3"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "95. contrib ports"
- title initialized to: "Memory Leak TCL 8.3.0 in TclAlloc"
- type initialized to: "Bug"
Ticket change [d3210ff228] (rid 113642) by dkf on 2001-01-25 17:03:21:
- subsystem changed to: "69. Other"
Ticket change [03b6d6f573] (rid 119871) by dkf on 2001-01-25 17:03:22:
- icomment:
Tcl deletes the interpreter when the final matching call to Tcl_Release (matching the calls performed to Tcl_Preserve) is called. In normal situations, this happens as the stack is unwound in the normal course of things - once an interpreter is deleted, no new commands can be called on it, so unwinding depends entirely on currently running code. Is there any reason you're not using the Tcl_Obj-based variable access functions? If nothing else, I understand how they manage memory allocation and free-ing better than with the string-based functions... :^)
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [69dd6ae4a3] (rid 128051) by dkf on 2001-01-31 17:48:10:
- subsystem changed to: "41. Memory Allocation"
Ticket change [569e8ce493] (rid 94351) by hobbs on 2001-08-07 07:29:57:
- assignee changed to: "hobbs"
Ticket change [c7f10998f4] (rid 122029) by hobbs on 2001-09-11 08:18:54:
- closedate changed to: "2001-09-11T01:18:54"
- closer changed to: "hobbs"
- icomment:
Logged In: YES user_id=72656 You may be getting confused that Tcl_Finalize isn't being called. The Tcl_Obj allocator can sometimes trick leak checkers, because Tcl block allocates objects that are kept through the lifetime of Tcl (until Tcl_Finalize is called). Certain objects are life outside the realm of a single interpreter, and could thus still be alive. Does this really increase by the same amount over multiple iterations of the Create/Delete cycle?
- login: "hobbs"
- mimetype: "text/plain"
- resolution changed to: "Invalid"
- status changed to: "Closed"
- username: "hobbs"