[plt-scheme] web-server memory use

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Mon Apr 30 14:17:21 EDT 2007

On 4/30/07, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> At Mon, 30 Apr 2007 10:02:32 -0400, "Jay McCarthy" wrote:
> > There is a bit of a problem, because the continuation manager is
> > reachable by the servlet custodian, and it touches all your
> > continuations, which touches all your instance data.
>
> Is there a particular custodian that should be charged for each
> continuation? (The instance's continuation?)

Yes that's right. I used the cust-box and experimented a bit, and it
seems to correct account the memory of the various servlet instances.
Direct implementation would be very useful. Currently, the server
relies on killing the instance custodian to free up memory. And, the
recent discussion demonstrates that that does not work.

Jay

> If so, I think you could use the following `make-cust-box' to insert a
> indirection from the continuation manager to each continuation:
>
>  (define (make-cust-box cust v)
>    (let ([ch (make-channel)])
>      (parameterize ([current-custodian cust])
>        (thread (lambda ()
>                  (let loop ()
>                    (channel-put ch v)
>                    (loop)))))
>      ch))
>
>  (define (cust-box-val l)
>    (channel-get l))
>
> If it it turns out to be the right idea, a direct implementaton of in
> MzScheme would be much cheaper (instead of requiring a whole thread and
> a context switch per access); a direct implementation also would be
> easy to add.
>
> Matthew
>
>


-- 
Jay McCarthy <jay.mccarthy at gmail.com>
http://jay.teammccarthy.org


Posted on the users mailing list.