AriSoft has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

Is there any new wisdom available about this old problem?

use threads; threads->create(sub {})->join while 1;
This simple code leaks memory when tested on Debian Lenny v5.10.0 and also with v5.10.1. It has also been discussed here some years ago.

Replies are listed 'Best First'.
Re: Status of memory leak problem?
by BrowserUk (Patriarch) on Apr 03, 2010 at 19:21 UTC

    What do you see if you run this?

    #! perl -slw use strict; use threads; use threads::shared; use Time::HiRes qw[ time ]; my $count :shared = 0; async{ my $last = $count; while( sleep 1 ) { my $now = $count; printf "%d threads/second\n", $now - $last; $last = $now; } }->detach; threads->create( sub { lock $count; ++$count; } )->join while 1;

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      I see RSS growing about 1M per second with 5.10.1 and 5.12.0-RC1, and about 1M per 3 seconds with 5.8.9

        Which platform, and what output from the program?


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Status of memory leak problem?
by Anonymous Monk on Apr 03, 2010 at 18:16 UTC
    Maybe you can link previous discussion /bug report? It doesn't leak on win32 5.10.1.
      Yes, You are right - it does not leak in Windows. Unfortinately sockets does not work properly threaded in windows and threads leaks memory in Linux. No system is perfect for threaded socket programming :-) One old discussion is Perl Threads and Memory Leaking and there are others too.