Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Yeah. I wish I understood, or one of the guys that know would tell us, where the memory growth actually arises.

If you run this (having substituted a suitable mem routine for your platform), and then play with the various values, it's really difficult to devine where the growth occurs and what controls how much?

#! perl -slw use strict; use Data::Dumper; use threads; use threads::shared; no warnings 'misc'; our $N ||= 100; our $D ||= 1.e5; our $SHARED; sub mem { my @filler = 1 .. $D unless @_; my @filler : shared = 1 .. $D if @_; my( $usage ) = `tasklist /NH /FI \"pid eq $$\" ` =~ m[ (\S+) \s+ +K \s* $ ]x; $usage =~ tr[,][]d; return 1024 * $usage; } my @data = 1 .. $D unless $SHARED; my @data:shared = 1 .. $D if $SHARED; printf "start : %6d\n", my $start = mem; for ( 1 .. $N ) { my $thread = threads->create( \&mem ); printf "%3d : %6d\n", $_, $thread->join; } printf "end : %6d\n", my $end = mem; printf "Growth: %6d\n", $end - $start;

Here are some typical results on my system:

c:\test\fork>..\534254 -N=10 -D=1 start : 3141632 1 : 3993600 2 : 4018176 3 : 4018176 4 : 4022272 5 : 4038656 6 : 4038656 7 : 4022272 8 : 4018176 9 : 4055040 10 : 4055040 end : 4034560 Growth: 892928 c:\test\fork>..\534254 -N=10 -D=1 -SHARED start : 3145728 1 : 3997696 2 : 4022272 3 : 4022272 4 : 4030464 5 : 4026368 6 : 4022272 7 : 4059136 8 : 4059136 9 : 4059136 10 : 4059136 end : 4042752 Growth: 897024 c:\test\fork>..\534254 -N=10 -D=1e3 start : 3211264 1 : 4128768 2 : 4149248 3 : 4149248 4 : 4157440 5 : 4149248 6 : 4153344 7 : 4157440 8 : 4161536 9 : 4157440 10 : 4198400 end : 4132864 Growth: 921600 c:\test\fork>..\534254 -N=10 -D=1e3 -SHARED start : 3555328 1 : 4345856 2 : 4378624 3 : 4382720 4 : 4386816 5 : 4395008 6 : 4390912 7 : 4390912 8 : 4390912 9 : 4386816 10 : 4395008 end : 4374528 Growth: 819200 c:\test\fork>..\534254 -N=10 -D=1e5 start : 9723904 1 : 17874944 2 : 17907712 3 : 17920000 4 : 17940480 5 : 17924096 6 : 17940480 7 : 17936384 8 : 17944576 9 : 17936384 10 : 17952768 end : 11743232 Growth: 2019328 c:\test\fork>..\534254 -N=10 -D=1e5 -SHARED start : 43819008 1 : 48697344 2 : 48721920 3 : 48726016 4 : 48726016 5 : 48730112 6 : 48730112 7 : 48730112 8 : 48734208 9 : 48738304 10 : 48738304 end : 44195840 Growth: 376832

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^2: threads: spawn early to avoid the crush. by BrowserUk
in thread threads: spawn early to avoid the crush. by BrowserUk

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-16 06:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found