The loaded modules aren't likely consuming much of import. Rather than prematurely optimize, either figure out how to measure the impact or find something actually useful to spend your time on.

I can see value in delaying the loading of such a large number of modules. But I find it hard to imagine how trying to unload them again would do anything other than consume more resources. The pages allocated to your process that your process doesn't touch are one of the least important resources in most situations are so are almost never worth trying to exert effort to optimize them.

For going from 138 modules loaded down to 4, it may even be more efficient to use "exec( $^X, $0, @ARGV );" to do that instead. And that is also less likely to cause breakage when you try to re-load the modules. Though, I wouldn't even bother with that unless I could find evidence of some real problem.

- tye        


In reply to Re: Is this a safe way to 'un'-require a module? (don't) by tye
in thread Is this a safe way to 'un'-require a module? by stevieb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.