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

Reduce circular references #3

Merged
merged 2 commits into from
Oct 26, 2024
Merged

Conversation

Baptouuuu
Copy link
Member

Problem

When running the ab command to test the performance of the http server on innmind/vendor-graphs. A bug appeared where some variables value was no longer available in memory.

The problem is due to too many circular references being set filling PHP's memory root buffer. Most of the circular references are due to the Fibers referencing the framework Application object (and all its versions, as each call of the middleware creates a new object). This is the case because the closure built to then be run to handle a request capture $this.

$this is captured to simplify accessing previous properties but only the properties are needed and not the whole Application object.

Solution

  • Declare local variables for the properties needed inside the closure and capture these variables instead of $this
  • Declare closures as static to make sure $this is never captured

@Baptouuuu Baptouuuu added the bug Something isn't working label Oct 26, 2024
@Baptouuuu Baptouuuu self-assigned this Oct 26, 2024
* develop:
  specify next release
  allow to use Service references everywhere
  fix class name in changelog
  fix psalm errors
Copy link

codecov bot commented Oct 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.63%. Comparing base (e723eb4) to head (b354b59).
Report is 3 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop       #3      +/-   ##
=============================================
+ Coverage      92.57%   92.63%   +0.06%     
  Complexity       100      100              
=============================================
  Files             15       15              
  Lines           1198     1209      +11     
=============================================
+ Hits            1109     1120      +11     
  Misses            89       89              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Baptouuuu Baptouuuu merged commit e8311ae into develop Oct 26, 2024
23 checks passed
@Baptouuuu Baptouuuu deleted the reduce-circular-references branch October 26, 2024 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant