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

Fix memory leak after rendering #3680

Merged
merged 3 commits into from
Oct 12, 2018
Merged

Conversation

YusukeOba
Copy link
Contributor

Issue Link πŸ”—

#3671
#3649

Goals ⚽

No memory leak.

Implementation Details 🚧

  • Added weak modifier to NSUIAccessibilityElement#container.
  • Added guard statements.

Testing Details πŸ”

I tested in example demo and my project.

@codecov-io
Copy link

codecov-io commented Oct 4, 2018

Codecov Report

Merging #3680 into master will decrease coverage by 0.05%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3680      +/-   ##
==========================================
- Coverage   31.06%   31.01%   -0.06%     
==========================================
  Files         114      114              
  Lines       10465    10482      +17     
==========================================
  Hits         3251     3251              
- Misses       7214     7231      +17
Impacted Files Coverage Ξ”
Source/Charts/Utils/Platform+Accessibility.swift 31.57% <ΓΈ> (ΓΈ) ⬆️
Source/Charts/Renderers/LegendRenderer.swift 53.06% <0%> (-0.92%) ⬇️
Source/Charts/Renderers/BarChartRenderer.swift 50.68% <0%> (-0.79%) ⬇️
...ce/Charts/Renderers/CandleStickChartRenderer.swift 0% <0%> (ΓΈ) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data
Powered by Codecov. Last update 86ae253...1fb45fb. Read the comment docs.

@YusukeOba
Copy link
Contributor Author

@liuxuan30
@petester42

Would you be able to review this source code?

I think there is a problem of cyclic reference by #1060.

Example in LineChartRenderer.

  1. Create and hold NSUIAccessibilityElement. depends on ChartView.
    https://github.com/danielgindi/Charts/blob/master/Source/Charts/Renderers/LineChartRenderer.swift#L621

  2. NSUIAccessibilityElement strong reference on ChartView.
    https://github.com/danielgindi/Charts/blob/98a472cf77a419e63a5a853b04515cb3d4f34079/Source/Charts/Utils/Platform%2BAccessibility.swift#L107

@pmairoldi pmairoldi self-assigned this Oct 10, 2018
@pmairoldi
Copy link
Collaborator

I’ll look at it sometime this weak

Copy link
Collaborator

@pmairoldi pmairoldi left a comment

Choose a reason for hiding this comment

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

Good catch. Looks good but this change needs to be applied to both macOS and iOS/tvOS variations. Just search for class NSUIAccessibilityElement you should find it easily.

@YusukeOba
Copy link
Contributor Author

Sorry about that. I fixed for macOS. πŸ˜ƒ

@pmairoldi pmairoldi merged commit 9c01bc9 into ChartsOrg:master Oct 12, 2018
@pmairoldi
Copy link
Collaborator

Thanks

@YusukeOba YusukeOba deleted the fix-memory-leak branch October 12, 2018 14:33
@YusukeOba
Copy link
Contributor Author

Thank you for your time. πŸ˜„

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

Successfully merging this pull request may close these issues.

4 participants