Click here to get back home

m// on very long lines leaks memory

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
m// on very long lines leaks memory ShaunJ 03-13-2008
Posted by xhoster on March 13, 2008, 6:01 pm
Please log in for more thread options
> The following snippet leaks memory until it breaks and falls down when
> m// is used on a very long line. It works fine if the line lengths are
> short. Try
> ./test.pl /usr/share/dict/words /usr/share/dict/words
> Depending on your dictionary, you'll see that compiling the regex
> takes about 200 MB. However the following matching loop leaks memory
> at an alarming rate. Start up `top` and watch it run. I'm using Perl
> 5.8.6 built for darwin-thread-multi-2level. If anyone cares to confirm
> or deny this behaviour for other architectures or version of Perl,
> that would be interesting too.

Technically, this does not seem to be a leak. If I throw in infinite
loop around your foreach my $re (@re) loop, then memory only grows
up to 15.5Gig when the inner loop completes. Upon the next iteration of
the outer loop, memory stops growing. So it seems like it is an
inefficiency rather than a leak. With idle speculation, I'd say that each
$re maintains some kind of independent state, that that state is
proportional to the size of the string it was last used on, and that that
storage is reused next time that $re gets invoked, but not before then.

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.

Similar ThreadsPosted
What to do about memory leaks July 20, 2007, 7:08 am
Memory leaks with SOAP Lite August 30, 2007, 10:40 am
perl open/close file leaks memory?? September 27, 2007, 1:30 am
long lines October 28, 2004, 12:25 pm
--chop-long-lines April 2, 2007, 10:04 am
split long string over two lines June 15, 2005, 10:22 pm
printLDIF wraps long lines of text October 22, 2004, 3:07 pm
Need help with leaks December 18, 2007, 4:45 pm
'long long integer' in Perl February 15, 2006, 2:30 pm
Huge Memory Load for reading into memory November 6, 2006, 7:10 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap