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 EstimatePlayerProgress memory usage #6631

Merged

Conversation

Lancej
Copy link
Contributor

@Lancej Lancej commented Sep 9, 2023

Reduce OnFrame memory allocation from about 4.5 MB/s to 0.1 MB/s when PoB is active and on tree tab.

Description of the problem being solved:

EstimatePlayerProgress is called many times per frame because it's used for the width of a control several other controls anchor off of. In the function a local table is created which allocates over 4 MB/s because of how often the function is called. The memory does eventually get garbage collected but this is extra work that isn't needed.

Moved the table to outside the function and did some other minor refactoring.

Steps taken to verify a working solution:

  • "pointDisplay" control at the top still displays correct points spent and the tooltip shows same progress as before
  • Toggling level mode between Manual and Auto still works

Before/After with PoB window active:
before after

@LocalIdentity LocalIdentity added the bug: behaviour Behavioral differences label Sep 9, 2023
@LocalIdentity LocalIdentity merged commit c943371 into PathOfBuildingCommunity:dev Sep 9, 2023
shafouz pushed a commit to shafouz/PathOfBuilding that referenced this pull request Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: behaviour Behavioral differences
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants