Hi Liz:
I figured out an alternative method to handling filehandles which is
working nicely so I'm back to dealing with the memory issue. Below you
will find some sample code I wrote this morning that simulates the
actual program. Basically the main thread launches a login thread which
is constantly looking for new login messages. When it sees one it
launches its own thread which performs some tasks and then detaches.
I'd like your opinion on the memory performance of the code below if you
have some time.
Thanks!
Steve
__CODE__
#!/usr/bin/perl -w
use strict;
use warnings;
# add some size with standard modules
use FileHandle;
use Test;
use Benchmark;
use CGI;
use Shell;
use FileCache;
use Exporter;
use AutoLoader;
use Env;
# necessary module
use threads;
#-------MAIN
my $sim_login_thr = threads->create(\&sim_login);
while (1) { } # end while (1)
#-------sub sim_login
sub sim_login {
print "Entering sim_login...\n";
my $thr = threads->tid;
print "This is thread: $thr\n";
my $loop_counter = 0;
while (1) {
$loop_counter++;
if ($loop_counter == 1) {
print "Sleeping 5 seconds before launching tasks thread\n";
sleep(5);
my $login_tasks_thr = threads->create(\&login_tasks)->detach;
} # end if ($loop_counter == 1)
} # end while (1)
} # end sub sim_login
#-------sub sim_login
sub login_tasks {
print "Entering login_tasks...\n";
my $thr = threads->tid;
print "This is thread: $thr\n";
print "Sleeping 5 seconds before detaching thread: $thr\n";
sleep(5);
print "Completed login_tasks...\n";
} # end sub login_tasks