Welcome to the Monastery | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
The behaviour is attributable to running out of resource (specifically C stack) when spawning the threads that underlie Win32's fork emulation. The 1s appear to be residual values from Perl's stack, possibly the return from print, that are being 'assigned' to $_? With a standard build of Perl, the 1s creep into the output when the number of concurrent forks (threads) exceeds ~120. Using AS811, using a string length of 9 exceeds this limit and produces a few ones at the end of the run
However, if you used a copy of perl that has had it's stack reservation reduced as I described in Use more threads., then you can run many more concurrent threads, and the "strange behaviour" goes away. The following version succeeds in starting well over 13,000 threads before consuming all my swap space and terminating for lack of memory.
Reduce the string to 'a' .. 'n' and it completes successfully with no sign of the mysterious 1s. Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In reply to Re: strange behaviour when forking lots of times
by BrowserUk
|
|