http://www.perlmonks.org?node_id=860860


in reply to Re^2: Strange memory leak using just threads
in thread Strange memory leak using just threads

Your platform--be it the pthreads or memory management or whatever--has an underlying problem that cannot be directly addressed by, nor attributed to, Perl.

Strangely this problem doesn't affect C and Python threaded programs.

  • Comment on Re^3: Strange memory leak using just threads

Replies are listed 'Best First'.
Re^4: Strange memory leak using just threads
by BrowserUk (Patriarch) on Sep 20, 2010 at 15:31 UTC

    Then that perhaps leave "or memory management or whatever".

    Of course, a memory management problem might be attributed to Perl if you are compling your perl with use_perl_malloc.

    See 860733, and (indirectly) dave_the_m comment.


    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.
      Now that's interesting. I didn't use use_perl_malloc (as you can see in the later comment from 860733 ), but I did use a bunch of -D's that I really have no idea what they do, they were just what was in the config for the stock 5.10 that came with deb lenny.

      I'm recompiling 5.12.2 now with just -des -Dprefix=$HOME/perl512 -Dusethreads.

      And bonk. It still seems to be leaking memory.

        I didn't use use_perl_malloc ...

        I'm recompiling 5.12.2 now with just -des -Dprefix=$HOME/perl512 -Dusethreads .

        Then perhaps the thing to do would be to try it with use_perl_malloc?

        I'd also try adding usemultiplicity, but this is all just speculation on my behalf.

        First thing you need to do really is get in contact with someone who has a *nix perl that doesn't exhibit the problem.


        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.

        If you search you will find that this subject was discussed here before a lot of times. Yes, perl threads leaking memory on Linux, and yet it seems nobody especially concerned about this. If your Perl program supposed to work on Linux there's no much sense to use threads. Perl threads is not the same thing as POSIX threads. Actually on Linux creating a new process with fork is usually cheaper than creating a new Perl thread both in terms of speed and memory. If you need to handle multiple IO streams, you should use POE, AnyEvent (this one BrowserUk wouldn't recommend I guess), or IO::Select in simple cases, and it will be more efficient than using threads. If you want to perform some CPU intensive operations, than multiprocess model will allow you to use several CPUs, and it is more scalable than multithread model. So what is the reason why are you want to use threads?