CCSpriteFrameCache发布策略 [英] CCSpriteFrameCache release strategy

查看:161
本文介绍了CCSpriteFrameCache发布策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据我的理解,从文件和sprites文件创建精灵时, CCSpriteFrameCache 被填充,并且应该足够聪明,在内存不足时清除未使用的帧。

As far as I understand the CCSpriteFrameCache gets filled when creating sprites from files and spritesheets and should be clever enough to purge unused frames when getting out of memory.

我的问题是:在我的应用程序中,我应该担心尽快手动释放未使用的框架,还是应该依赖缓存在必要时清除自己?

My question is: in my app should I worry about manually releasing unused frames as soon as possible or should I just rely on the cache to purge itself when necessary?

是否有任何副作用(如系统或其他正在运行的应用程序的整体性能问题)让缓存增长,直到获得内存警告?

Is there any side-effect (like overall performance issue of the system or of other running apps) in letting the cache grow until getting memory warning?

推荐答案

这真的取决于你的应用程序和它的内存占用。在我的一个游戏中,我积极地清除内存,并加载及时,当游戏处于这样的情况下,重新加载将不会添加不当的滞后,这可能是用户的关闭。

The answer to that truly depends on your app, and its memory footprint. In one of my games, I aggressively purge memory, and load 'just in time', when the game is in a circumstance where the reload will not add undue lags that could be a turn-off for the user.

但是正如我所说,你的策略应该基于内存占用的实际测量,以及它对用户体验的感知影响。一如往常,在模拟器上开始测量(测量记忆,但NOTOK测量时间和FPS),但在实际设备上快速验证一些测量。

But as I said, your strategy should be based on actual measurements of the memory footprint, and its 'perceived' impact on user experience. As always, start your measurements on the simulator (OK for measuring memory but NOTOK for measuring time and FPS), but quickly validate with some measurements on real devices.

这篇关于CCSpriteFrameCache发布策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆