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

内存泄露 #2

Open
ghost opened this issue Jul 17, 2018 · 3 comments
Open

内存泄露 #2

ghost opened this issue Jul 17, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Jul 17, 2018

1.存在严重的内存泄露。ChartView 滑动时存在线性的内存增长。
ZYWCandleChartView.m
CGMutablePathRef redRef = CGPathCreateMutable();
CGMutablePathRef greenRef = CGPathCreateMutable();
这个需要手动释放。
// add
CGPathRelease(redRef);
CGPathRelease(greenRef);

2.浏览了代码,思路是在scrollview上放置ChartView。
这样做是有问题的,数据不断增长,ChartView的宽度可以无限变大。

3.可以只绘制当前界面需要显示的K线,减少不必要的开销。

@249109296
Copy link

请问如何做到只绘制当前界面需要显示的k线?

@378804441
Copy link

请问如何做到只绘制当前界面需要显示的k线?

可以做一个类似轮播似的, 三个界面轮训绘制k线数据。这样的话 不会无限创建出view了

@ghost
Copy link
Author

ghost commented Oct 11, 2018

请问如何做到只绘制当前界面需要显示的k线?

我写了一个demo,借鉴了Cocoa-Charts的实现方式
https://github.com/stonelay/ZLKLineDemo
CoreAnimation实现,不会影响主线程,目前看起来效率不错。

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

No branches or pull requests

2 participants