Improve memory consumption by using static progress callback without binding to promise #115
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.
This builds on top of the ideas discussed in #46. The third
$progress
callback passed to the resolver is deprecated as of #112 and as such should not be used for most applications.This PR ensures that this callback never causes a cyclic garbage reference as discussed in #46. This builds on top of the work done in #113. If you do not access any arguments, this PR has no effect (also no performance or memory penalty).
If you do access any of the arguments, you no longer have to care about this method memory wise, as it will no longer cause a cyclic garbage reference. A similar patch will follow for the other two callbacks, but I figured it's worth discussing this concept on its own first.
Invoking the benchmarking example from #113 shows that this has no little effect on performance (1M invocations that do no use arguments show no performance improvements, 1M invocations that do use arguments show a ~4% performance degradation).
This PR actually includes a test that shows how garbage memory references can be avoided in PHP 7+ and how this method does no longer cause any such references on its own.