You could check for $& and freinds having been used somewhere in a library using Devel::SawAmpersand.

However, I tried running the following minimal emulation of your code:

#! perl -slw use strict; use Carp; use threads; use threads::shared; $| = 1; our $N ||= 2; our $SIZE ||= 1e6; my $semaphore :shared = 0; my $running : shared = 0; 'abc' =~ m[b] and print "$`:$&:$'"; ## Use ampersand. my $bigString = 'ACTG' x $SIZE; for ( 1 .. $N ) { async { printf "Thread %s starting\n", threads->tid; ++$running; my $count = 0; while( $bigString =~ m[ACTG]g ) { #lock $semaphore; #print threads->tid, ' : ', pos( $bigString ); ++$count; } --$running; printf "Thread %s stopping ($count)\n", threads->tid; }; } Win32::Sleep 100 until $running; Win32::Sleep 100 while $running;

With and without the highlighted line and it doesn't cause a crash on my system even when running 100 threads and a 10e6 char sequence. It runs hugely more slowly, but that is expected.

The only thing I can see missing from my simplified version is Bio::SeqIO (Darn thing will never install here!). As a test, you could try substituting this crude Fasta sequence load code (taken from Re: Forking Multiple Regex's on a Single String (use threads))

## Crude fasta load--Expects 1 sequence per file open my $fh, '<', $path or croak "$path : $!\n"; <$fh>; ## discard header ( my $sequence = do{ local $/; <$fh> } ) =~ s[\s+][]g; close $fh;

and remove the dependancy upon that module and see what if any difference that makes.

Beyond that, you could try running my emulation above on your system and see if that also causes the Out of memory failure.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^5: Memory Usage in Regex On Large Sequence by BrowserUk
in thread Memory Usage in Regex On Large Sequence by bernanke01

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.