> If I run the following script:
>
> for {set i 0} {$i<100000} {incr i} {
>  lappend temp [list one two three four five six seven eight nine]
> }
> ns_return 200 text/plain [string bytelength $temp]
>
> memory usage soars but is not reclaimed by Aolserver.
>
> I've tested this on Aolserver3.5.6 TCL 8.4.3 and Aolserver4 beta 10 TCL
> 8.4.4 Platform:FreeBSD 5.1-RELEASE

This is fully explainable.  AOLServer uses a threaded Tcl, which uses
a specialized threaded memory allocator for speed.  This allocator
works on the high water mark principle.  AOLServer also does interp
pooling (last I checked).  OK, groundwork laid ...

> If I restart nsd and change the script to use append instead of lappend
> Aolserver reclaimes memory and the nsd process shrinks after execution.
> The same is true if the list is not nested.

OK, append is just taking all these as strings and adding them onto one
string object, whereas lappend, being a list operation, maintains each
of the items as *separate* *individual* Tcl_Objs.

> I thought this might be a problem with TCL but when I run the following
> script from a shell, memory is reclaimed after the variable was unset.

Ah ... variable unsetting now.  Note you never did that before in the
AOLServer version.  This is key to release the refcounts that you have
been adding up for the var.  Also, as AOLServer pools, that var might
not be getting cleaned up properly.  In any case, you will end up with
quite a lot of extra Tcl_Obj's allocated which remain around for the
next use of that thread.  They will release the mem of what they were
containing (although the AOLServer threaded malloc may not), but the
Tcl_Objs themselves are pooled by the Tcl core.

In any case, this wholly bogus example does highlight some of the mem
characteristics of the core/AOLServer, but there are many ways to control
real bloat.  Perhaps if you should some more real code we could assist in
pointing out what may be awry.

  Jeff Hobbs                     The Tcl Guy
  Senior Developer               http://www.ActiveState.com/
        Tcl Support and Productivity Solutions


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of 
your email blank.

Reply via email to