in reply to Re: Re: Improving memory performance
in thread Improving memory performance

Remember, use also does an import. If the module exports any subs, they will take up a small amount of space in each namespace they are imported into. That's what he was referring to.
  • Comment on Re: Re: Re: Improving memory performance

Replies are listed 'Best First'.
Re: Re: Re: Re: Improving memory performance
by Sihal (Pilgrim) on Oct 04, 2002 at 15:38 UTC
    So if I use a same module a multiple time in a script ( ie main calls module A, module A calls B and C but C also calls B and A ) the only memory I waste is by exporting the subs in each namespace ?
      That's correct. The module is only compiled once, but the imports happen in each namespace where the script is used, and they take up space. You can always simply avoid importing by calling a module with an empty import list, like this:
      use Foo::Bar ();
Re: Re: Re: Re: Improving memory performance
by Sihal (Pilgrim) on Oct 06, 2002 at 16:53 UTC
    Yes Perrin, I forgot that... so to minimize wasting of space maybe i should not always rely on exporting all the subs, but create groups and import them explicitely. ( like, i have an all purpose module that has grown quite big, with utility fincs, maybe I should import only whats needed in each script. Any ideas of how much memory it costs to import a func?
      Your goal should be to import nothing at all. Importing makes code more confusing and is kind of a crutch for doing perl4 style things in perl5. However, information on how much memory it costs is available here.