Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Asynchronous processes currently spawn with PHP's default memory limit (whatever's configured in php.ini). In my case, I increase this limit as needed in certain scripts using ini_set. This lead to a problem where these scripts would spawn processes that run out of memory... even though the memory limit was increased in the script, the sub-processes would all get the smaller default memory limit from php.ini and silently crash. Not ideal and tough to debug!
This PR adds a memoryLimit method to the Pool class that lets you configure a memory limit for each process spawned by the pool. You can specify a specific memory limit (using bytes, KB, M, etc.). Or, if you leave the parameter out, it will calculate how much memory is remaining in the parent script and divide it by the concurrency value--spreading out the remaining memory to the number of processes expected to be running. If you don't call the memoryLimit method at all, nothing happens--making this feature backwards-compatible.