Menu

#2921 Obj Memory Leak

obsolete: 8.4.7
closed-invalid
5
2004-10-19
2004-10-19
lisong
No

sorry my poor english.

but i think that follow funtion in tclobj.c need to add
some code to avoid memory leak.

void
TclFinalizeCompExecEnv()
{
register Tcl_Obj *objPtr;

Tcl_MutexLock(&tableMutex);
if (typeTableInitialized) {
Tcl_DeleteHashTable(&typeTable);
typeTableInitialized = 0;
}
Tcl_MutexUnlock(&tableMutex);
Tcl_MutexLock(&tclObjMutex);

//{ lisong 2004-10-19
// add to fix memory leak of objptr
while (tclFreeObjList != NULL)
{
objPtr = tclFreeObjList;
tclFreeObjList = objPtr-
>internalRep.otherValuePtr;
}
free(objPtr);
//} lisong

Tcl_MutexUnlock(&tclObjMutex);

TclFinalizeCompilation();
TclFinalizeExecution();
}

Discussion

  • miguel sofer

    miguel sofer - 2004-10-19

    Logged In: YES
    user_id=148712

    No. The Tcl_Obj are allocated in a pool, you cannot free
    them independently (except if tcl was compiled with
    -DPURIFY, in which case there is not tclFreeObjList, and the
    core handles the freeing already).

    The free objects are not properly freed by tcl. They are
    kept around for reuse, and tcl relies on the OS to release
    the memory at exit. See the comments in the function
    TclAllocateFreeObjects(), in generic/tclObj.c

     
  • miguel sofer

    miguel sofer - 2004-10-19
    • status: open --> closed-invalid