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:
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.
|