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

用了之后发现更耗内存了是正常现象吗? #22

Open
ApesTalk opened this issue Oct 20, 2016 · 4 comments
Open

用了之后发现更耗内存了是正常现象吗? #22

ApesTalk opened this issue Oct 20, 2016 · 4 comments

Comments

@ApesTalk
Copy link

ApesTalk commented Oct 20, 2016

你好,我有一个列表页面,每个Cell里面有一个UIImageView,用的Masonry布局,在模拟器上测试的。
当我用:

_logoView.layer.borderWidth = 0.5f;
_logoView.layer.borderColor = HEXCOLOR(0xdddddd).CGColor;
_logoView.layer.cornerRadius = 3;
_logoView.layer.masksToBounds = YES;

的情况下,等页面全部加载完毕,内存不再变化的时候显示的是56.3MB。
当我用:

[_logoView zy_cornerRadiusAdvance:3 rectCornerType:UIRectCornerAllCorners];
[_logoView zy_attachBorderWidth:0.5 color:HEXCOLOR(0xdddddd)];

的情况下,等页面全部加载完毕,内存不再变化的时候显示的是60.7MB。

而且每次运行跑起来对比,都是使用你的这个方法比使用cornerRadius和masksToBounds方法更消耗内存一点,这个属于正常现象吗?

@liuzhiyi1992
Copy link
Owner

liuzhiyi1992 commented Oct 20, 2016

@lqcjdx 个人用大量圆角图片测试过内存应该是不会高于传统切角方法的,目前出现大多数内存增加的原因是cell的重用问题,朋友可否检查下cell是否开启了重用?

有空我再回归测试下内存问题,或者朋友有demo分享下给我们检查问题更好

@ApesTalk
Copy link
Author

@liuzhiyi1992 cell肯定是重用了的。demo我没法给呀,我这边就是一个列表,每个cell上一个UIImageView,用SDWebImage来加载的网络图片的,每个图片地址都不一样的那种。你可以试试看加载个50~100个cell后等内存消耗量稳定下来后是多少MB。

@liuzhiyi1992
Copy link
Owner

image
这个是老版本的内存检测数据,目前版本我抽空再检查下

@trhyl
Copy link

trhyl commented Mar 14, 2017

虽然这样的drawRect保证了帧率避免了offscreen,但是确实存在占用过多内存和cpu的消耗。
推荐:- -

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

3 participants