Hi all , I am using threads in my code , and somewhere in Perl documentation I saw that I shall use queues for threading - if I dont want any memory leaks. Today , I have big scripts that can simoultaniously run 24 threads , which I can see - after the threads end, the memory doesnt clean itself. I read about queues to threads in Perl , but I didnt got the idea, so I need a little help there. Is the idea is creating some pool of lets say 10 threads , and every time there is a job - the job is sent to an available thread ? my need is to each thread to return something when it ends - which I put inside a hash , and then use this hash. Can some one help me with that and explain me the theory ? thanks ! this is my current code
#Start new thread my $t1 = threads->new (\&$functions_name1,@parameters1); push(@threads,$t1); my $t2 = threads->new (\&$functions_name2,@parameters2); push(@threads,$t2); my $index=0; my %hash_results = (); foreach my $thread (@threads) #wait for all threads untill the end +and insert results to hash { $hash_results{$index}=$thread->join; }

In reply to Threads memory consumption by mojo2405

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.