develooper Front page | perl.perl5.porters | Postings from October 1999

Re: perlthread.pod -- First draft of thread docs

Thread Previous | Thread Next
Jason Arnold
October 22, 1999 16:49
Re: perlthread.pod -- First draft of thread docs
Message ID:
Two things:

1)  I assume the cavet still exists that locks don't dictatorially lock still
exists.  If so, it's probably wise to mention that (unless I was completely
asleep and missed the warning).

2)  Are threads still beta?  They still leak (at least in Linux (2.2.5) with Perl
5.005_62) memory, although I'm quite pleased with the CPU overhead (kudos whoever
worked on them).  I suspect that it may be both perl and linux related at it
leaks less under 5.005.62 than 5.005_03 and less with a 2.2.13 kernel than a
2.2.5 kernel.  People should at least be warned that, as the header says, "There
be dragons here..."

I.e. see below example that leaks about a MB/hour (leaks with join also, but for
my uses, detach is preferrable)...


use Config;

# Go threaded...
 $Config{usethreads} or die "Recompile Perl with thread support...\n";
 use Thread;

# Declare Threaded Subs...
 sub ScanChildren  {
  # Persistant values for children...

  while (1) {
   my $aqThr = new Thread \&AnalyzeQuery;

   my $aiThr = new Thread \&AnalyzeInsert;

   my $auThr = new Thread \&AnalyzeUpdate;


 sub AnalyzeQuery  {
  use attrs qw(locked);
  my $foo = 1;


 sub AnalyzeInsert  {
  use attrs qw(locked);
  my $foo = 1;


 sub AnalyzeUpdate  {
  use attrs qw(locked);
  my $foo = 1;


# End initialization / declaration

 # Start up main child monitor thread...
 $sc_thr = new Thread \&ScanChildren;


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About