You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rivet-dev@tcl.apache.org by "David N. Welton" <da...@dedasys.com> on 2002/03/13 12:17:06 UTC

memory

In Rivet_SendContent:

    globals = ap_pcalloc(r->pool, sizeof(rivet_interp_globals));
    globals->r = r;
    globals->req = (TclWebRequest *)ap_pcalloc(r->pool, sizeof(TclWebRequest));
    interp = rsc->server_interp;
    Tcl_SetAssocData(interp, "rivet", NULL, globals);

I wonder if we could move the alloc somewhere else...  that might save
us some space.

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org


Re: memory

Posted by "David N. Welton" <da...@dedasys.com>.
Damon Courtney <da...@your.unreality.com> writes:

>     Yeah, in theory, we shouldn't have to decrement the count since
> we never incremented it.  It should just be freed at the end of the
> routine.  Hrmm.... Maybe one of the functions we're calling on the
> object is incrementing its reference count.  I dunno'.  Tcl is
> usually pretty good about not doing stuff like that.
 
See my comp.lang.tcl post about the same issue.  Don Porter says that
it doesn't matter if the refcount is zero, but rather, that it gets
decremented to 0 or less.  Infact:

#   define Tcl_DecrRefCount(objPtr) \
	if (--(objPtr)->refCount <= 0) TclFreeObj(objPtr)

Sigh...  I wish Tcl were a bit more modern sometimes.

>     So, commit some changes and let's see if we can't clean all
> these up.  0-]

The problem is that I commented out the GetConf stuff... I guess I can
uncomment, commit, then recomment.

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org


Re: memory

Posted by Damon Courtney <da...@your.unreality.com>.
> davidw@dedasys.com (David N. Welton) writes:
> 
> > In Rivet_PropagatePerDirConfArrays:
> > 
> >     return;
> >     arrayName = Tcl_NewStringObj( "RivetDirConf", -1 );
> > 
> > keeps it from growing, but switching the two makes it bloat.
> > 
> > WTF!?  I must be completely missing something.  Maybe Tcl has a small
> > leak?  We are talking about a lot of requests... but still....hrm.
> 
> A few of these:
> 
>     Tcl_DecrRefCount(arrayName);
> 
> keep that function from leaking memory.  Mine is no longer leaking, at
> this point:-)

    Yeah, in theory, we shouldn't have to decrement the count since
we never incremented it.  It should just be freed at the end of the
routine.  Hrmm.... Maybe one of the functions we're calling on the object
is incrementing its reference count.  I dunno'.  Tcl is usually pretty
good about not doing stuff like that.

    So, commit some changes and let's see if we can't clean all these up.
0-]

D


---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org


Re: memory

Posted by "David N. Welton" <da...@dedasys.com>.
davidw@dedasys.com (David N. Welton) writes:

> In Rivet_PropagatePerDirConfArrays:
> 
>     return;
>     arrayName = Tcl_NewStringObj( "RivetDirConf", -1 );
> 
> keeps it from growing, but switching the two makes it bloat.
> 
> WTF!?  I must be completely missing something.  Maybe Tcl has a small
> leak?  We are talking about a lot of requests... but still....hrm.

A few of these:

    Tcl_DecrRefCount(arrayName);

keep that function from leaking memory.  Mine is no longer leaking, at
this point:-)

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org


Re: memory

Posted by "David N. Welton" <da...@dedasys.com>.
In Rivet_PropagatePerDirConfArrays:

    return;
    arrayName = Tcl_NewStringObj( "RivetDirConf", -1 );

keeps it from growing, but switching the two makes it bloat.

WTF!?  I must be completely missing something.  Maybe Tcl has a small
leak?  We are talking about a lot of requests... but still....hrm.

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org


Re: memory

Posted by "David N. Welton" <da...@dedasys.com>.
davidw@dedasys.com (David N. Welton) writes:

> Hrm... on my Linux box, it seems to be growing by about 4 bytes every
> 50 requests or so, although it's not exact.  That number doesn't
> really ring a bell.  Strange that it's not doing it per-request.

in SendContent I tried this:

    Rivet_PropagatePerDirConfArrays( interp, rdc );
    return HTTP_BAD_REQUEST;/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXX  */

and

    return HTTP_BAD_REQUEST;/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXX  */
    Rivet_PropagatePerDirConfArrays( interp, rdc );

The first one eats memory (albeit slowly), the second one doesn't.

Hrm... so, going to check that out...

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org


Re: memory

Posted by "David N. Welton" <da...@dedasys.com>.
Hrm... on my Linux box, it seems to be growing by about 4 bytes every
50 requests or so, although it's not exact.  That number doesn't
really ring a bell.  Strange that it's not doing it per-request.

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org


Re: memory

Posted by Damon Courtney <da...@your.unreality.com>.
> > In Rivet_SendContent:
> > 
> >     globals = ap_pcalloc(r->pool, sizeof(rivet_interp_globals));
> >     globals->r = r;
> >     globals->req = (TclWebRequest *)ap_pcalloc(r->pool, sizeof(TclWebRequest));
> >     interp = rsc->server_interp;
> >     Tcl_SetAssocData(interp, "rivet", NULL, globals);
> > 
> > I wonder if we could move the alloc somewhere else...  that might save
> > us some space.
> 
> Well, even if that memory does get freed, this is probably better done
> in the Tcl init section anyway, so I moved the global alloc and
> SetAssocData there.

    Probably a good idea.  The memory is allocated in the pool for the
request, so when the pool is destroyed, the memory is freed.  But, I
agree that it's probably a better place for it. 0-]

D


---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org


Re: memory

Posted by "David N. Welton" <da...@dedasys.com>.
davidw@dedasys.com (David N. Welton) writes:

> In Rivet_SendContent:
> 
>     globals = ap_pcalloc(r->pool, sizeof(rivet_interp_globals));
>     globals->r = r;
>     globals->req = (TclWebRequest *)ap_pcalloc(r->pool, sizeof(TclWebRequest));
>     interp = rsc->server_interp;
>     Tcl_SetAssocData(interp, "rivet", NULL, globals);
> 
> I wonder if we could move the alloc somewhere else...  that might save
> us some space.

Well, even if that memory does get freed, this is probably better done
in the Tcl init section anyway, so I moved the global alloc and
SetAssocData there.

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org