>>>>> "Dan" == Dan Wickstrom <[EMAIL PROTECTED]> writes:



    Dan> It appears that the splitList method is only called from
    Dan> within the setListFromAny method The setListFromAny method is
    Dan> then used in most of the TclList methods.  It's not clear to
    Dan> me why the TclList object and the underlying Tcl_Obj wouldn't
    Dan> get cleaned up.


Further investigation shows that the corresponding setListFromAny call
is made from the TclList.getString method.  As an example here is a
section from ArrayObject.java:

   case OPT_SET:
        if (numArgs != 2) {
            throw new TclNumArgsException(interp, optionIdx + 1, argv,
                    "indexList value");
        }
        if (convert == false) {
            throw new TclException(interp,
                 "-noconvert flag not allowed for the \"set\" sub-command");
        }

        indexListObj = argv[optionIdx + 1];
        numDims = TclList.getLength(interp, indexListObj);
        if (numDims == 0) {
            subArrayObj = javaObj;
            subArrayClass = dereferenceClassDims(interp, javaClass, 1);
            index = 0;
        } else {
            // Dereference all but the last dimension specified.  Set
            // the value of index'th element of the "subArrayObj" to
            // the value in argv[optionIdx + 2].

            subArrayObj = dereferenceArrayDims(interp, javaObj,
                    numDims, indexListObj);
            subArrayClass = dereferenceClassDims(interp, javaClass, numDims);
            index = TclInteger.get(interp, 
                    TclList.index(interp, indexListObj, numDims - 1));
        }

        // Set the value of the index'th element of "subArrayObj" to the value
        // in the TclObject argv[optionIdx + 2].

        setArrayElt(interp, subArrayObj, subArrayClass, index, argv[optionIdx + 2]);
        interp.resetResult();
        return;

The TclList.getLength method converts indexListObj to a TclList object
which uses an underlying Tcl_Obj to hold the internal rep.  At the end
of this case statement, it returns leaving indexListObj with no
references.  The jvm garbage collects indexListObj, but the underlying
Tcl_Obj is left stranded and results in a memory leak.

-Dan


----------------------------------------------------------------
The TclJava mailing list is sponsored by Scriptics Corporation.
To subscribe:    send mail to [EMAIL PROTECTED]  
                 with the word SUBSCRIBE as the subject.
To unsubscribe:  send mail to [EMAIL PROTECTED] 
                 with the word UNSUBSCRIBE as the subject.
To send to the list, send email to '[EMAIL PROTECTED]'. 
An archive is available at http://www.mail-archive.com/tcljava@scriptics.com

Reply via email to