in reply to perl threads & memory
What OS and Perl version do you run? How do you measure the heap? Your code is running on my machine (Win7, cygwin, Perl 5.14.4) for 6 minutes now and I see no problem.