J
Jon Combe
I have some Perl code that uses threads but found that after running
for a few days the memory usage had increased dramatically. I
simplified the code to the following but find when I run it with a
varying number of threads, the memory usage always increases. The
"countdown" at the end is just there to give me 30 seconds to grab the
memory utilisation before the process ends. I find that it uses approx
70MB for 50,000 threads, 140MB for 100,000 threads and 210MB for
150,000 threads.
I've tried on Perl 5.8.8, 10.2 and 12.2 all with similar results. Is
this a bug or have I just done something wrong? Any help appreciated!
#!/usr/bin/perl -w
use strict;
use threads;
use threads::shared;
for ( my $i = 0 ; $i < 150000 ; $i++ )
{
my $thread = threads->create('thread_function');
$thread -> join();
if ( $i % 1000 == 0 )
{
printf ( "%010i\n" , $i );
}
}
print "DONE\n";
for ( my $i = 0 ; $i < 30 ; $i++ )
{
print "Count down " . (30-$i) . "\n";
sleep(1);
}
sub thread_function
{
}
Thanks.
Jon
for a few days the memory usage had increased dramatically. I
simplified the code to the following but find when I run it with a
varying number of threads, the memory usage always increases. The
"countdown" at the end is just there to give me 30 seconds to grab the
memory utilisation before the process ends. I find that it uses approx
70MB for 50,000 threads, 140MB for 100,000 threads and 210MB for
150,000 threads.
I've tried on Perl 5.8.8, 10.2 and 12.2 all with similar results. Is
this a bug or have I just done something wrong? Any help appreciated!
#!/usr/bin/perl -w
use strict;
use threads;
use threads::shared;
for ( my $i = 0 ; $i < 150000 ; $i++ )
{
my $thread = threads->create('thread_function');
$thread -> join();
if ( $i % 1000 == 0 )
{
printf ( "%010i\n" , $i );
}
}
print "DONE\n";
for ( my $i = 0 ; $i < 30 ; $i++ )
{
print "Count down " . (30-$i) . "\n";
sleep(1);
}
sub thread_function
{
}
Thanks.
Jon