There is quite a bit of writing on how to reduce your memory footprint with mod_perl. It mostly involves pre-loading modules at startup so they will be shared. Perl does not provide a way to effectively remove compiled code from memory, so the answer to your question is no. If you have an extreme case (for example, you very occasionally use LWP, which takes up a lot of memory), you can deal with it by waiting to load the module until you actually need it (with a require call) and telling the current apache process to exit when the request is over (
). Apache::SizeLimit will do this for you if you load a module that pushes the current size over the limit.