Skip to content
Tcl Source Code History Of Ticket 229969
Login

History Of Ticket 229969

Artifacts Associated With Ticket 229969

  1. Ticket change [af970e2811] (rid 97841) by nobody on 2001-01-24 21:36:26:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. 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);
      ?
      
    4. foundin initialized to: "obsolete: 8.3"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "95. contrib ports"
    10. title initialized to: "Memory Leak TCL 8.3.0 in TclAlloc"
    11. type initialized to: "Bug"
  2. Ticket change [d3210ff228] (rid 113642) by dkf on 2001-01-25 17:03:21:

    1. subsystem changed to: "69. Other"
  3. Ticket change [03b6d6f573] (rid 119871) by dkf on 2001-01-25 17:03:22:

    1. 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...  :^)
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  4. Ticket change [69dd6ae4a3] (rid 128051) by dkf on 2001-01-31 17:48:10:

    1. subsystem changed to: "41. Memory Allocation"
  5. Ticket change [569e8ce493] (rid 94351) by hobbs on 2001-08-07 07:29:57:

    1. assignee changed to: "hobbs"
  6. Ticket change [c7f10998f4] (rid 122029) by hobbs on 2001-09-11 08:18:54:

    1. closedate changed to: "2001-09-11T01:18:54"
    2. closer changed to: "hobbs"
    3. 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?
      
      
    4. login: "hobbs"
    5. mimetype: "text/plain"
    6. resolution changed to: "Invalid"
    7. status changed to: "Closed"
    8. username: "hobbs"