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

Re: [perl #26785] mem leak in split

Yitzchak Scott-Thoennes
February 18, 2004 16:22
Re: [perl #26785] mem leak in split
Message ID:
On Tue, Feb 17, 2004 at 02:56:38PM -0000, "Ohlman, Jeff" wrote:
> I am trying to split a record twice - the 2nd split takes an element of the first split and splits it again.  Trying to assign the results of the 2nd split to another array causes the OS to produce:
> Out of memory during request for 1008 bytes, total sbrk() is 64858324 bytes!
> I've reduced the program to the bare min in order to reproduce the error.  This is the offending code:
> perl -ne 'chomp;@x=split(/< /,$_);@r=split(/~/,$x[1]);'">!@ <mailto:!@> >/,$_);@r=split(/~/,$x[1]);' reallybigfile.dat
> The work around is:
> perl -ne 'chomp;@x=split(/< /,$_);($a">!@ <mailto:!@> >/,$_);($a, $b, $c, $d, $e) =split(/~/,$x[1]);' reallybigfile.dat

Those don't look like valid perl.  I think you might have left
something out.  In any case, could you try putting my(@r); before
using @r and let us know if this helps?  That will disable an
optimization that might be causing the trouble. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About