Skip to content
Tcl Source Code View Ticket
Login

View Ticket

procs created by TCL_CreateInterp() leaks memory

Closed / Works For Me218385ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:56:57
OriginalBugID: 4553 Bug
Version: 8.2
SubmitDate: '2000-03-24'
LastModified: '2000-03-27'
Severity: SER
Status: Closed
Submitter: techsupp
ChangedBy: hobbs
RelatedBugIDs: 4552 4503
OS: Windows NT
FixedDate: '2000-10-25'
ClosedDate: '2000-03-27'


Name:
Kent Bloomstrand

ReproducibleScript:
It seems redefining the same procs (non-compiled) within a single 
TCL interp created by TCL_CreateInterp() will also cause memory 
leak (per Mark Scheevel's suggestion). 

How to reproduce: 

Compile and run the following C program (similar to the one from Step 3). 
The file "d:/temp/plain.tcl" ("*file" in the following program) is the 
same simple TCL file from Step 1 before with 600 simple procedures 
such as 'proc ::ns::proc_a {} {return 1}': 

int main(int argc, char* argv[]) 
{ 
    // code to re-eval the same set of non-compiled TCL procs 250,000 times 
    int i, j, status; 
    char tmp[32766]; 
    char *file = "d:/temp/plain.tcl"; 
    char cmd_string[32766]; 
    FILE *fp; 
    Tcl_Interp *interp; 

    if (NULL != (fp = fopen(file, "r"))) { 
        strcpy(cmd_string, "namespace eval :: {\n"); 
        while (! feof(fp)) { 
            (void) fgets(tmp, 2048, fp); 
            strcat(cmd_string, tmp); 
        } 
        strcat(cmd_string, "}\n"); 
    } 
    fclose(fp); 

    interp = Tcl_CreateInterp(); 
    for (i = 0 ; i < 10000 ; i++) { 
        printf("%d...", i); 
        for (j = 0 ; j < 100 ; j++) { 
            printf("."); 
            status = Tcl_GlobalEval(interp, cmd_string); 
            if (status != TCL_OK) { 
                printf("namespace eval failed\n"); 
                return 1; 
            } 
        } 
        printf("\n"); 
    } 
    Tcl_DeleteInterp(interp); 

    printf("Hit RETURN when done..."); 
    getchar(); 
    return 0; 
}

ObservedBehavior:
it leaks

DesiredBehavior:
no leak



This particular case is not reproducable, but may be related to
4552 (use of 'namespace export cmd1' causes monotonic memory
growth, but *not* a leak), or 4503, which points out that tbcload
has a leak in repeated sourcing of the same file. 
-- 03/27/2000 hobbs
welch Closed ticket [218385ffff]. [History diff]2000-10-26 08:21:16
dgp Ticket [218385ffff]: 4 changes [History diff]2001-04-19 02:52:14
Log in (anonymous is fine) to add a comment.