module load question

Discussion in 'Perl Misc' started by Chuck Mattern, Nov 27, 2003.

  1. I've been asked to take a look at some very badly written Perl in use on a
    number of our servers. One of the issues is that as it runs it consumes more
    and more memory. I've only had a chance to do a cursory read of the code but
    one thing that intrigued me was a directive to use a module that was inside of
    a loop, with each iteration the module was called again. Is it possible that
    this is part of the memory consumption? Would each reference load a new copy
    of the same module in another segment of memory leaving the previous copies in
    memory as well or would the new one be ignored or would each new call overwrite
    the previous copy?

    Looking forward to the thoughts of group,
    Chuck
    --
    -----------------------------------------------------------------------
    |Chuck Mattern | "People often find it easier to be a result |
    | | of the past than a cause of the future." |
    -----------------------------------------------------------------------
    Chuck Mattern, Nov 27, 2003
    #1
    1. Advertising

  2. In article <>,
    Chuck Mattern <> wrote:

    > I've been asked to take a look at some very badly written Perl in use on a
    > number of our servers. One of the issues is that as it runs it consumes more
    > and more memory. I've only had a chance to do a cursory read of the code but
    > one thing that intrigued me was a directive to use a module that was inside
    > of
    > a loop, with each iteration the module was called again. Is it possible that
    > this is part of the memory consumption? Would each reference load a new copy
    > of the same module in another segment of memory leaving the previous copies
    > in
    > memory as well or would the new one be ignored or would each new call
    > overwrite
    > the previous copy?


    Neither. Perl is smarther than that.

    perldoc -f use

    says (amongst other things:

    >It is exactly equivalent to
    >
    >BEGIN { require Module; import Module LIST; }
    >


    and:

    > The `BEGIN' forces the `require' and `import' to
    > happen at compile time. The `require' makes sure
    > the module is loaded into memory if it hasn't been
    > yet.



    if its already loaded, "use"ing it again does nothing... You'll need to
    look somewhere else for your problem...

    cheers,

    big

    --
    'When I first met Katho, she had a meat cleaver in one hand and
    half a sheep in the other. "Come in", she says, "Hammo's not here.
    I hope you like meat.' Sharkey in aus.moto
    Iain Chalmers, Nov 27, 2003
    #2
    1. Advertising

  3. Chuck Mattern

    Tore Aursand Guest

    On Wed, 26 Nov 2003 23:29:59 -0500, Chuck Mattern wrote:
    > I've only had a chance to do a cursory read of the code but one thing
    > that intrigued me was a directive to use a module that was inside of a
    > loop, with each iteration the module was called again. Is it possible
    > that this is part of the memory consumption?


    No;

    perldoc -f use

    See for yourself; Move the 'use' parts out of the loops and let the
    program run for a while, and you should see that it still eats up memory.
    Alas, your problem seems to be elsewhere.


    --
    Tore Aursand <>
    "A teacher is never a giver of truth - he is a guide, a pointer to the
    truth that each student must find for himself. A good teacher is
    merely a catalyst." -- Bruce Lee
    Tore Aursand, Nov 27, 2003
    #3
  4. Tore Aursand <> writes:

    > On Wed, 26 Nov 2003 23:29:59 -0500, Chuck Mattern wrote:
    > > use a module that was inside of a
    > > loop, with each iteration the module was called again. Is it possible
    > > that this is part of the memory consumption?


    > See for yourself; Move the 'use' parts out of the loops and let the
    > program run for a while, and you should see that it still eats up memory.
    > Alas, your problem seems to be elsewhere.


    Many thanks, in my heart I knew that would be too easy...

    --
    -----------------------------------------------------------------------
    |Chuck Mattern | "People often find it easier to be a result |
    | | of the past than a cause of the future." |
    -----------------------------------------------------------------------
    Chuck Mattern, Nov 27, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mad Scientist Jr
    Replies:
    7
    Views:
    1,144
    Emma Gumbdough
    Jun 30, 2004
  2. venky

    Page Load and webcontrol page load

    venky, Jul 6, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    3,078
    venky
    Jul 11, 2005
  3. roni
    Replies:
    1
    Views:
    637
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tp?=
    Aug 30, 2005
  4. Maric Michaud
    Replies:
    0
    Views:
    7,180
    Maric Michaud
    Jun 24, 2006
  5. =?Utf-8?B?cm9kY2hhcg==?=

    to load or not to load

    =?Utf-8?B?cm9kY2hhcg==?=, Aug 29, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    315
    Mark Rae
    Aug 30, 2006
Loading...

Share This Page