develooper Front page | perl.perl5.porters | Postings from February 2011

Re: [perl #77854] Memory leak using threads

Thread Previous
From:
Dave Mitchell
Date:
February 24, 2011 08:38
Subject:
Re: [perl #77854] Memory leak using threads
Message ID:
20110224163755.GG2883@iabyn.com
On Sat, Sep 18, 2010 at 11:33:06AM +0100, Dave Mitchell wrote:
> On Tue, Sep 14, 2010 at 08:52:19AM -0700, Jon Combe wrote:
> > I have a Perl script using threads and have found that when it has been
> > running for a period of time the memory usage gets very high (around
> > 1GB). I have managed to find the problem seems to be thread related. To
> > help isolate the problem I created the simple Perl script below. This
> > simply spawns a fixed number of threads and each thread simply
> > increments and then decrements a thread counter. At the end, the code
> > checks the thread count is zero (it should be) and then counts down from
> > 1 to 30. This gives me 30 seconds to capture the final memory usage
> > prior to the script ending. I have observed the following memory usage
> > when changing the number of threads in the first "for" loop in terms of
> > memory usage when running the script:-
> > 
> > Thread Count            VIRT MEM        RES MEM
> > 50000                   106m            93m
> > 100000                  195m            181m
> > 150000                  287m            275m
> > 
> > Note that this output is from a version of Perl I compiled myself. I've
> > also tried with the version of Perl that comes packaged with CentOS 5.4
> > (5.8.8) and that comes with Ubuntu 10.2 (Perl 5.10.1) with similar
> > results. I've also tried removing the shared variable ($thread_count)
> > and making the subroutine entirely empty with the same results. I
> > suspect therefore it's a memory leak in creating threads.
> 
> I can reproduce this on 5.8.8, but not 5.10.0, 5.12.0 nor 5.13.4.

With optimised, non-debugging builds I can reproduce this on
5.12.[23], 5.13.[012347], but not on
5.13.[5689], 5.13.10

So I'm assuming it was fixed in 5.13.5,
broken again in 5.1.3.7,
and fixed again in 5.13.9

-- 
All wight. I will give you one more chance. This time, I want to hear
no Wubens. No Weginalds. No Wudolf the wed-nosed weindeers.
    -- Life of Brian

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About