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 Leak in Horizontal Bar Chart #2745

Closed
chuynadamas opened this issue Aug 23, 2017 · 9 comments
Closed

Memory Leak in Horizontal Bar Chart #2745

chuynadamas opened this issue Aug 23, 2017 · 9 comments

Comments

@chuynadamas
Copy link
Contributor

Leak in horizontal bar chart

I just find a leak on the horizontal bar chart, you can reproduce it if you open your demo project hit the horizontal bar chart example multiple times and then check the memory graph, i'll add some screen about how it looks.

Retain cycle

screen shot 2017-08-22 at 8 02 05 pm

Objects created

screen shot 2017-08-22 at 8 02 13 pm

I checked on your history issues, it seems that you guys have one related an apple bug, is this the same problem #2425 I'm using your latest version.

Thanks in advance :)

@liuxuan30
Copy link
Member

liuxuan30 commented Aug 23, 2017

It's different in #2425. This is about the CALayer and the view itself.
How to read this graph, especially malloc?

I tried instruments, it indeed looks like CALayer has leak (as well as the chart view itself):
image

Also, I added dealloc in horizontal bar chart view controller, when popping back, dealloc is called, but the chart view seems hold by something and cannot released:

2017-08-23 10:37:06.365 ChartsDemo[60964:24310892] hori. dealloc!
(lldb) po self
<HorizontalBarChartViewController: 0x7fde16f36e50>

(lldb) po self.chartView
<Charts.HorizontalBarChartView: 0x7fb064e033e0; frame = (0 47; 375 437); autoresize = RM+BM; gestureRecognizers = <NSArray: 0x60800005dbe0>; layer = <CALayer: 0x6000002241a0>>

After dealloc is finished, in runtime:

(lldb) po 0x7fde16f36e50  // view controller
140591844519504

(lldb) po [0x7fb064e033e0 retainCount]  // self.chartView
0x0000000000000001

(lldb) po [0x6000002241a0 retainCount]  // self.chartView.layer
0x0000000000000001

I am not sure what causes the leak right now, as we don't touch CALayer. Can someone help?

If not, I could personally file a DTS request to Apple to help when I got time on this.

@liuxuan30
Copy link
Member

I checked CALayer's stack trace, there is one unpaird group which looks like to your memory graph, but I don't understand right now.
image

@liuxuan30
Copy link
Member

@chuynadamas can you try on a real device with older iOS version? I don't have old simulator right now nor device. I can try find a iOS 9 device maybe tomorrow.

@chuynadamas
Copy link
Contributor Author

chuynadamas commented Aug 23, 2017

@liuxuan30 I did the test with a real device running 10.3.3 I don't have devices with older versions, maybe tomorrow i could find one too or download an old simulator.

@liuxuan30
Copy link
Member

liuxuan30 commented Aug 29, 2017

I asked a UIKit dev on twitter but no response at all.. Seems need a DTS or bug report. I am not sure if it's on us or Apple's bug. Looks like it's apple as we don't manage CALayer on our side

@liuxuan30
Copy link
Member

filed a radar: 34298100

@DamirDjozicCoing
Copy link

DamirDjozicCoing commented Dec 7, 2017

I posted a comment on this memory leak issue on other thread. Please check that and let me know if that solves the issue.

#2772

Hope that helps!

@liuxuan30
Copy link
Member

this issue seems more like for #3078 rather than #2772

liuxuan30 added a commit to liuxuan30/Charts that referenced this issue Dec 8, 2017
liuxuan30 added a commit that referenced this issue Dec 8, 2017
@liuxuan30
Copy link
Member

liuxuan30 commented Dec 8, 2017

@chuynadamas reopen(if you can) if this does not solve yours.

FreddyZeng added a commit to FreddyZeng/Charts that referenced this issue Jan 2, 2018
* 'master' of https://github.com/danielgindi/Charts: (23 commits)
  Update ViewPortHandler.swift (ChartsOrg#3143)
  add option to build demo projects unit tests on iOS (ChartsOrg#3121)
  Replaced relevant `ChartUtils` methods with `Double` extensions (ChartsOrg#2994)
  Update 4.0.0 with master (ChartsOrg#3135)
  Removed redundant ivars in BarLineChartViewBase (ChartsOrg#3043)
  fix ChartsOrg#1830. credit from ChartsOrg#2049 (ChartsOrg#2874)
  Makes ChartsDemo compiling again (ChartsOrg#3117)
  Fixed using wrong axis (Issue ChartsOrg#2257)
  Removed methods and properties deprecated in 1.0 (ChartsOrg#2996)
  for ChartsOrg#3061 revert animationUpdate() and animationEnd() not trigger crash if subclass does nothing
  The backing var is not necessary. (ChartsOrg#3000)
  Replaced `ChartUtils.Math` in favour of an extension on `FloatingPoint` (ChartsOrg#2993)
  Minor logic cleanup (ChartsOrg#3041)
  Fix a bug may cause infinite loop. (ChartsOrg#3073)
  for ChartsOrg#2745. chart should be weak.
  fileprivate -> private (ChartsOrg#3042)
  Removed `isKind(of:)`
  Removed @objc from internal properties
  Fixes for PR
  Made use of `==` where appropriate to simplify logic
  ...

# Conflicts:
#	Source/Charts/Data/Implementations/Standard/LineChartDataSet.swift
#	Source/Charts/Renderers/BarChartRenderer.swift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants