ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> incrtcl-users
incrtcl-users
Re: [Incrtcl-users] ::itcl::delete class leaks?
by Jeff Hobbs other posts by this author
Jun 6 2006 3:44PM messages near this date
Re: [Incrtcl-users] ::itcl::delete class leaks? | Re: [Incrtcl-users] ::itcl::delete class leaks?
You are correct that the mcode-> procPtr should be checked as well.  In fact,
the firstLocalPtr doesn't need to be checked, because Itcl_DeleteArgList will
check for NULL itself, but I'll leave that in.
 
Jeff 

-----Original Message-----
From: Tyukodi Zolt�n [mailto:tyukodi.zoltan@[...].hu] 
Sent: June 6, 2006 2:31 AM
To: Jeff Hobbs
Cc: incrtcl-users@[...].net
Subject: RE: [Incrtcl-users] ::itcl::delete class leaks?



Hello Jeff,

 

thank you for the help. 

 

Isn�t it necessary to check if mcode-> procPtr is null before the line:

 

} else if (mcode-> procPtr->firstLocalPtr) {

 

Zolt�n Tyukodi


  _____  


From: Jeff Hobbs [mailto:jeffh@[...].com] 
Sent: Friday, June 02, 2006 19:51
To: Tyukodi Zolt�n
Cc: incrtcl-users@[...].net
Subject: RE: [Incrtcl-users] ::itcl::delete class leaks?

 

Hi Zolt�n,

 

Attached is a bit more conservative variant of the same patch.  I do believe
it is correct (passes all tests, plus one new one).  I have commited this to
CVS.

 

Thanks,

  Jeff Hobbs, The Tcl Guy, http://www.ActiveState.com/ 

-----Original Message-----
From: Tyukodi Zolt�n [mailto:tyukodi.zoltan@[...].hu] 
Sent: June 1, 2006 12:08 AM
To: Jeff Hobbs
Cc: incrtcl-users@[...].net
Subject: RE: [Incrtcl-users] ::itcl::delete class leaks?

Hello Jeff,

 

thank you for your suggestion but unfortunately it is not allowed me to modify
the class.

I have spent 4 days to investigate the source code of the itcl and now I think
that the problem is in the Itcl_DeleteMemberCode function. I have made the
following modification on it:

 

Original version of the Itcl_DeleteMemberCode function:

 

void

Itcl_DeleteMemberCode(cdata)

    CONST char* cdata;  /* pointer to member function definition */

{

    ItclMemberCode* mcode = (ItclMemberCode*)cdata;

 

    if (mcode-> arglist) {

        Itcl_DeleteArgList(mcode-> arglist);

    }

    if (mcode-> procPtr) {

        ckfree((char*) mcode-> procPtr->cmdPtr);

 

        /* don't free compiled locals -- that is handled by arglist above */

 

        if (mcode-> procPtr->bodyPtr) {

            Tcl_DecrRefCount(mcode-> procPtr->bodyPtr);

        }

        ckfree((char*)mcode-> procPtr);

    }

    ckfree((char*)mcode);

}

 

 

 

 

Fixed (by me) of version of the Itcl_DeleteMemberCode function:

 

void

Itcl_DeleteMemberCode(cdata)

    CONST char* cdata;  /* pointer to member function definition */

{

    ItclMemberCode* mcode = (ItclMemberCode*)cdata;

 

    if (mcode-> arglist) {

        Itcl_DeleteArgList(mcode-> arglist);

    }

    if (mcode-> procPtr) {

 

        ckfree((char*) mcode-> procPtr->cmdPtr);

 

        /* don't free compiled locals -- that is handled by arglist above, if
there are arguments */

        if ( !( mcode-> arglist ) ) {

            Itcl_DeleteArgList( mcode-> procPtr->firstLocalPtr );

        }

 

        if (mcode-> procPtr->bodyPtr) {

            Tcl_DecrRefCount(mcode-> procPtr->bodyPtr);

        }

        ckfree((char*)mcode-> procPtr);

    }

    ckfree((char*)mcode);

}

 

 

The compiled local variables are not freed, if there is not any argument of
the itcl member procedure. Am I right?

I think that You are one of the developers of the itcl. Is it possible that
You validate my modification?

 

Thank You very much.

 

Zolt�n Tyukodi

 


  _____  


From: Jeff Hobbs [mailto:jeffh@[...].com] 
Sent: Tuesday, May 30, 2006 18:23
To: Tyukodi Zolt�n; incrtcl-users@[...].net
Subject: RE: [Incrtcl-users] ::itcl::delete class leaks?

 

Itcl is apparently not cleaning up after itself properly.  I verified the
leak, then just changed "set n 1" to "set ::n 1", ensuring a single global var
is used, and there was no longer a leak.

  Jeff Hobbs, The Tcl Guy, http://www.ActiveState.com/ 

-----Original Message-----
From: incrtcl-users-admin@[...].net
[mailto:incrtcl-users-admin@[...].net] On Behalf Of Tyukodi Zolt�n
Sent: May 30, 2006 12:38 AM
To: incrtcl-users@[...].net
Subject: [Incrtcl-users] ::itcl::delete class leaks?

Hello,

 

can anybody tell me why the following script leaks memory intensively?

 

 

package require Itcl

 

while { 1 } {

 

      ::itcl::class LeakClass {

            proc leakProc {} {

                  set n 1

            }

      }

 

      LeakClass::leakProc

 

      ::itcl::delete class "LeakClass"

}

 

 

There is no leak, if I remove the call of the procedure or the set n 1 line.

I know, this is a stupid algorithm but I have to do a similar one.
Thread:
Tyukodi Zoltán
Tyukodi Zoltán
Jeff Hobbs
Jeff Hobbs
Michael Thomas

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved