MnkyBrain has asked for the wisdom of the Perl Monks concerning the following question:
I'm using perl v5.10.0 on a debian lenny system (perl package version 5.10.0-19lenny2) and I'm experiencing a very strange memory leak in a threaded program.
I started stripping down the code to try to find what was causing it (assuming the problem was coming from one of the modules I was using), and was pretty surprised when I got it down to just the threading code, and was still seeing the memory leak. Here's the code:
#! /usr/bin/perl use strict; use warnings; use threads; my @child; my @list = qw(a b c d); while (1) { foreach(@list){ push(@child,threads->create("test","$_")); } foreach my $ch (@child) { $ch->join(); } @child = (); } sub test { my ($item) = @_; }
As you can see, there is absolutely nothing going on other than thread creation/joining, yet this script leaks memory like a sieve on my machine.
Can anyone tell me what I've done wrong?
Back to
Seekers of Perl Wisdom