I have a piece of code here that uses Thread::Queue. I wrote it as a test case when I was rooting around with Devel::Leak. This sucker will eat every ounce of memory I have and then my lunch if I let it. Can anyone tell me why? For some reason, it seems like dequeue does not free up the memory when it dequeues. Should I be using a different module?
smiles
#!/usr/bin/perl use strict; use threads; use Thread::Queue; my $q = Thread::Queue->new(); for (1..3) { $q->enqueue('A' x 100); threads->new(\&ttest) } my @threadlist = threads->list; sleep 100; $q->enqueue(undef) for @threadlist; $_->join for @threadlist; sub ttest { while (my $item = $q->dequeue) { my $cnt = $q->pending; print "$cnt\n"; $q->enqueue('A' x 100); } }
In reply to Thread::Queue and Memory by petesmiley
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |