develooper Front page | perl.perl5.porters | Postings from February 2003

Re: [perl #20569] Out of memory! message

Thread Previous
From:
hv
Date:
February 9, 2003 19:32
Subject:
Re: [perl #20569] Out of memory! message
Message ID:
200302100334.h1A3YCi15668@crypt.compulink.co.uk
"NGEOW, YIN" (via RT) <perlbug-followup@perl.org> wrote:
:I am running some perl script under SVR4 operating system using the
:following versions of perl (sum -r)
:05057    90 perl
:05057    90 perl5.00404
:29747    56 perlbug
:13716    25 perldoc
:I got the message Out of memory! 
:we have 100265984 bytes of memory in the processor with the following info .
[...]
:Please advise how to resolve this issue. Thanks

Most likely you are encountering a bug either in the perl program you
are running or in perl itself.

If it is a bug in perl itself, it has probably been fixed by now - try
downloading and installing a more recent version of perl (the latest
is 5.8.0) and see if the problem persists.

If the problem is in your code, try first to determine where in the
code the problem occurs by adding diagnostics - the bug may become
obvious when you do that. If not, try step by step to cut down the
program to the shortest possible example that gives the error, and
then send that example to this same address along with the output
from "perl -V".

One thing that can often cause this sort of problem is if you use
a reference as the subscript of an array, eg:
  my $arrayref = [ "array", "ref" ];
  my $element = @array[$arrayref];

Perl coerces any expression used as an array index to an integer;
a reference, when coerced to an integer, returns the value of its
location in memory, which is usually a large number. Using this
large number as the index into the array then causes perl to try
to extend the array to be large enough, which can cause the out of
memory error you are seeing. This is just one example of how things
can go wrong - you need to look at the code you are running.

Hope this helps,

Hugo van der Sanden

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About