There are several threads here on how to use a module conditionally and the consequences of the different ways to do that. Check out the replies to Checking to see if a particular Module is installed and error message if module doesn't exist? (the latter one doesn't go into as much detail but does have some new ideas not mentioned in the first thread).

You can certainly reduce memory use by not loading modules that you will not be using. Also, if you have a very big module that you only use a few routines of, then you might want to patch the module to use autoloading so that start-up time and memory consumption are reduced.

Yes, you can "unuse" a module but that won't return the memory to the operating system on most operating systems, including Win32 (it makes the memory available for Perl to reuse for other things, though). Note that pages of memory that aren't actively being used will only consume swap space, not real memory, so you might just want to add more swap space if you are running low on that.

        - tye (but my friends call me "Tye")

In reply to (tye)Re: Modules and memory use by tye
in thread Modules and memory use by randomblue

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.