develooper Front page | perl.perl5.porters | Postings from November 2014

[Fwd: Re: [perl #123198] Memory leak in regex appears in 5.20.1]

Thread Next
November 15, 2014 04:27
[Fwd: Re: [perl #123198] Memory leak in regex appears in 5.20.1]
Message ID:
---------------------------- Original Message ----------------------------
From:    "Dave Mitchell via RT" <>
Date:    Fri, November 14, 2014 7:03 am

The poster in LinkedIn's "Perl" discussion group is Nimrod Shlomo Chotzen

Initial message:

I switched this week to using perl-5.20.1, and I try to run an old (but
working) script on it. in this loop in loop in one function which iterates
around 50000 time

foreach my $key_word (grep {/\w+/} @keywords) {
if ($string_to_check =~


the memory usage increases very fast. at the next call of that function it
continues to increase, until it just freezes my machine.

I simplified the regexp to this:
$string_to_check =~ m/(?<=\W)\Q$key_word\E(?=\W|(s|es|ies\W))/i)
and now it's working great. Though I still wonder when will the next
eruption of memory occur :)
Response to a request for sample data:

there are no two different datasets. just different perls 5.18.2 and
5-20.1(where the memory leak occurs) the dataset is very simple: about
50000 terms: one words,two words or three words.

something like: "lantern,green lantern,green lantern
movie,movie,reviews,bad reviews,bad movie,bad movie reviews"...I can't
give the real set...


It looks like a failure to free memory in the handling of regex patterns.
If that area was changed between 5.18.2 & 5.20, that's probably where it
If this isn't sufficient, I'll try to elicit more clues.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About