Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leaks / method invocation side effects. #422

Closed
wants to merge 1 commit into from

Conversation

badrutdinovrr
Copy link
Contributor

First of all, thank you for your awesome framework!
Unfortunately, a method \Go\Aop\Framework\AbstractMethodInvocation::__invoke doesn't free references to method arguments as soon as have been invoked which results in:

  1. Memory leaks
  2. Unintended side effect: the argument object destructor isn't called.

I hope my small pull request will help your cool project to become a bit better.
Thank you!

@lisachenko
Copy link
Member

Hello! Thank you for the PR.

As master branch is not ready for release yet, please rebase your PR on 2.x branch, so I will be able to release a quick patch.

Also, there are some issues in review, please fix them before merging

@@ -93,6 +93,11 @@ public function __construct(string $className, string $methodName, array $advice
if ($this->level > 0) {
[$this->arguments, $this->instance, $this->current] = array_pop($this->stackFrames);
}
else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put else on the previous line after figure bracket.

else {
$this->arguments = [];
$this->instance = null;
$this->current = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, align all consecutive assignments. Also, $this->current is updated each time in the recursive calls, I'm not sure that your patch support recursive calls. I would suggest to drop this line entirely, clear only arguments and instance variables

@badrutdinovrr
Copy link
Contributor Author

Closing this in favor of #423

@scrutinizer-notifier
Copy link

The inspection completed: No new issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants