Trap memory overflow
am 14.11.2007 10:45:45 von alexxx.magni
I remember reading time ago that trapping memory overflow wasnt easy
in Perl.
Damn, now I have to allocate a lot of info in a 3dim structure:
my @AAA; # 1st index: image index; 2nd: x coord; 3rd: y coord
....
$AAA[$i][$x][$y]=....
....
and it surely overflows since at some time the AAA structure does not
contains my info anymore - after of course having run for some hours
without problems ...
can somebody tell me how to trap the overflow?
thanks for any help!
Alessandro
Re: Trap memory overflow
am 14.11.2007 13:24:27 von Ben Morrow
Quoth "alexxx.magni@gmail.com" :
> I remember reading time ago that trapping memory overflow wasnt easy
> in Perl.
No. If you must try, see $^M in perlvar, and take note of the fact that
you'll probably have to rebuild perl to use it.
> Damn, now I have to allocate a lot of info in a 3dim structure:
>
> my @AAA; # 1st index: image index; 2nd: x coord; 3rd: y coord
> ...
> $AAA[$i][$x][$y]=....
> ...
>
> and it surely overflows since at some time the AAA structure does not
> contains my info anymore - after of course having run for some hours
> without problems ...
That isn't memory exhaustion. Perl will exit with an untrappable error
when it runs out of memory, so you have some other problem.
Ben
Re: Trap memory overflow
am 14.11.2007 15:55:00 von rvtol+news
alexxx.magni@gmail.com schreef:
> my @AAA; # 1st index: image index; 2nd: x coord; 3rd: y coord
> ...
> $AAA[$i][$x][$y]=....
Is "image index" a consecutive range, starting at 0?
What is on the ...., a filename maybe? Maybe including a rather lengthy
and static path part?
Why not store the [$x,$y] as tuples?
my @AAA;
$AAA[0] = {
xy => [$x, $y ],
fn => "123.gif",
};
--
Affijn, Ruud
"Gewoon is een tijger."
Re: Trap memory overflow
am 14.11.2007 20:29:34 von xhoster
"alexxx.magni@gmail.com" wrote:
> I remember reading time ago that trapping memory overflow wasnt easy
> in Perl.
>
> Damn, now I have to allocate a lot of info in a 3dim structure:
>
> my @AAA; # 1st index: image index; 2nd: x coord; 3rd: y coord
> ...
> $AAA[$i][$x][$y]=....
> ...
>
> and it surely overflows since at some time the AAA structure does not
> contains my info anymore
Perl does not respond to OOM conditions by randomly deleting data.
Something else is going on.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.