in reply to Lots of memory usage with fork&copy

I just ran both scripts on my system copying a 32 MB file locally. I don't have a handy VPN 'd windows share, but it's hard to see how that would make any difference to the perl code action/performance.

In both cases, I saw zero memory growth. For the first script, memory fluctuated between 3.18MB and 3.27MB. For the second, between 3.680MB & 3.8MB. These flutations are simply snapshots as the process creates and destroys threads and are perfectly normal.

Which version of perl are you using?

Does it make any difference whether you copy the file locally?


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.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."
  • Comment on Re: Lots of memory usage with fork&copy

Replies are listed 'Best First'.
Re^2: Lots of memory usage with fork&copy
by andreidf (Novice) on Apr 27, 2007 at 14:28 UTC
    Here is a image of resources usage:
    http://img266.imageshack.us/img266/6838/perlfh2.png
    The memory grows until I suspend the process (or windows says: Enough memory, Rest in Peace! ;) ).

    The "use Win32;" follows: http://img266.imageshack.us/my.php?image=perlokvu7.png

    As i said before "I run this scripts with perl v5.8.8 on Windows XP. (Binary build 817, ActiveState, 20 Mar 2006)."

    I've tried it with both an empty file and a 49MB file. With and empty file the memory usage grows faster because it forks faster.

    I've run the scripts on local files.

    Edit: g0n - linkified web links

      FYI: The use of a fileshare and File::Copy are both incidental to the problem. The following one-liner demonstrates the memory growth under both 5.8.8 and 5.9.5.

      The second one-liner also demonstrates that use Win32; definitely has the effect of slowing the growth rate:

      ## leaks rapidly. The sleep just avoids a fork bomb. \as817\perl\bin\perl.exe -le"while(Win32::Sleep 10){$p=fork and waitpi +d($p,0) or print(qq[kid:$$]),exit}" ## This leaks more slowly \as817\perl\bin\perl.exe -mWin32 -le"while(Win32::Sleep 10){$p=fork an +d waitpid($p,0) or print(qq[kid:$$]),exit}"

      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.
        With waitpid (used in that form) you won't create a fork bomb so there's no need for sleep. I'll test on monday with an older perl if I'll found an installation kit on the internet.

      Sorry. That's the problem with coming to the party late, you tend to miss what has gone before. In this case, the reference to 5.8.8/AS817. I was using AS811/5.8.6 which I have stuck with in preference to 5.8.8 as I have encountered several anomolies with the latter.

      I just repeated my tests using AS817 and replicated your results exactly. I also tried it with 5.9.5 (current - 10 days), and found that it produces similar results to 5.8.8, so it looks like bug introduced since 5.8.6 is responsible. Worth raising a perl-bug report I think.


      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.