----- Original Message -----
From: "Shawn Devlin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, June 29, 2001 8:18 PM
Subject: Re: API Design Question



> What I like about this is I can add a new function without needing to
> disturb the existing code. Also, each function call is then
> self-contained. Currently, my existing API script is essentially a big
> switch statement.

I see the point in separating it. I do the same thing myself.


> My concern is that each handler links the .pm files so with 50 or so
> functions I will have 50 or so copies of the various .pm files in memory.

That's not quite right. In its simplest form, I can say that Apache gets one
copy of each module per *child*, not per file, so 50 files doesn't mean
you'll have 50 modules loaded. For example, if one child serves /api/foo,
and /api/foo loads API1.pm and API2.pm, those will stay in memory, so that
when the same child serves /api/bar, and /api/bar attempts to use API1.pm
and API2.pm, the perl interpreter will find out that these 2 modules have
already been loaded, and not reload them.

But if you use preloading, as you should do, you get even more benefit from
shared memory. If you preload your modules in starup.pl or with PerlModule
in httpd.conf, they'll stay shared in memory, thus reducing the memory
overhead.

Per Einar Ellefsen

Reply via email to