Cagao has asked for the wisdom of the Perl Monks concerning the following question:

Firstly is it possible to un-use a module to free up memory?

But now to my main query, I have this code for my SOAP Server...
use SOAP::Transport::HTTP; my $daemon = SOAP::Transport::HTTP::Daemon -> new (LocalPort => 8123, Reuse => 1) -> dispatch_to('/home/rob/www.intelcompute.com/site/cgi-bin', 'SOA +PServer'); print "Contact to SOAP server at ", $daemon->url, "\n\n"; $daemon->handle;
I took a note of memory usage once the daemon starts, then after one call it loads the module i'm dispatching to, and the memory goes up, which is fine, but is it possible to un-load the module once that call is finished with to keep the server load down? If not it's obviously better to simply 'use' all the modules I'm going to use, but it'd be nicer not to do that. This is for a VERY busy server (current loads reach 150 on a good day!)

And finally, does anyone know if I could fork() this script off to handle simultaneous requests on the same port? or does it do it for me? I don't think I saw any mention in the docs.

I'd like to use the daemon method rather than apache CGI to keep the server load down (no need for any other Apache functionality).

Thanks

Replies are listed 'Best First'.
Re: SOAP dispatch_to, but unload later
by shmem (Chancellor) on Jul 01, 2007 at 07:08 UTC
    While you can sort of "unload" a package by undefining its symbol table hash (be sure to free up all objects of that package first, or they'll be hanging around in the __ANON__ package) and removing the package file entry from %INC, that won't gain you much, since perl won't give back memory to the OS. Then, for the next request, you would reload that package anyways?

    If you are not using apache, you have to set up your listener by yourself, it is not provided by this module. You could go with Net::Server to implement it, if you don't want to go the Apache route. Be aware there's also FastCGI besides mod_perl.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}