Sorry if i'm not doing this right, still rather new to perl and new to this website. This keeps happening to me and i'm not sure why, i've written scripts that will check to see if a webpage is accessible and if it is I use threads to make a new thread in the program to notify me via twitter (just testing, the sub will do other things) I use a while(1) loop to continually check the webpage via WWW::Mechanize, and if its live, it'll create the threads, what happened a couple times if the program runs for awhile, is that when it goes to create the thread, i get an Out Of Memory error and i'm not sure how to avoid this.
--Code-- use WWW::Mechanize; use HTTP::Cookies; use threads; $|=1; my $cookie_jar = HTTP::Cookies->new; $mech = WWW::Mechanize->new( agent => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:21.0)', cookie_jar => $cookie_jar, timeout => "15", autocheck => 0); $url = 'http://www.fwrd.com/product-military-boots/YEF3-MZ2/'; # page will default to error page if not around... $delay = 15; check(); sub check { print "[x] starting...\n"; while(1) { $resp = $mech->get($url); if((!$resp->is_success) || ($resp->request->uri =~ m/error/i)) { print "."; } else { for $sz (1..5) { $thread = threads->new( sub { notify_plz($sz) }); my $tid = $thread->tid; push (@Threads, $thread); $thread->detach(); } # we saw the page , exit exit; # end what we do if its found } sleep $delay; } }
not sure what i'm doing wrong,any help is appreciated, didnt post notify_plz cuz the script doesnt even seem to get to that point.

In reply to keep running out of memory, help a newbie! by kixsnap

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.