Re: [Incrtcl-users] ::itcl::delete class leaks?
by Michael Thomas other posts by this author
Jun 2 2006 2:10PM messages near this date
Re: [Incrtcl-users] ::itcl::delete class leaks?
|
[Incrtcl-users] ::itcl::delete class leaks?
I've added this patch to the Fedora Core 4, 5, and rawhide releases of
itcl. Updated packages should hit the update mirrors in the next day or so.
--Mike
Jeff Hobbs wrote:
> 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.
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Incrtcl-users mailing list
> Incrtcl-users@[...].net
> https://lists.sourceforge.net/lists/listinfo/incrtcl-users
Thread:
Tyukodi Zoltán
Tyukodi Zoltán
Jeff Hobbs
Jeff Hobbs
Michael Thomas
|