减少 iOS (iPad) 上 Phonegap、sencha touch 的内存占用
我使用 Sencha Touch 1.1 和 PhoneGap 在 iPad 上部署代码。在 Instruments 中,内存使用量显示为大约 140MB(虚拟内存),然后在某些地方确实上升到超过 200MB,并且我的应用程序有时会由于大型列表而被终止,我正在修复这些列表以减少 DOM 占用。我尝试从 Safari 测试 sencha touch 应用程序,内存没有增长到这些限制,Safari 启动时约为 160MB,后来增加到 200+ MB,但大多数时候都停留在 170-180MB 范围内。
我的下一个测试是找出 PhoneGap 框架的影响。当我安装phonegap并尝试时,示例Hello world应用程序似乎已经使用了大约100 MB(虚拟内存)。我尝试在网络上搜索以确定如何减少此足迹,但没有找到任何内容。
我的问题如下 - 我可以做什么来减少phonegap足迹,它是否与帮助减少我的应用程序崩溃有关?我看到像 Flipboard 这样的其他应用程序本身使用的内存要少得多(60-70 MB),并且试图理解为什么 Phonegap 应用程序的基本占用空间是 100+ MB,而这个基于 PhoneGap + sencha-touch 的应用程序却徘徊在150 - 200 MB 范围。
阿南德
I am using Sencha Touch 1.1 along with PhoneGap to deploy code on the iPad. In Instruments the memory usage shows up at around 140MB (virtual memory) and then does go up at some places to higher than 200 MB and my app gets killed at times due to large lists which I am fixing to reduce the DOM footprint. I tried testing out the sencha touch app from Safari and the memory did not grow to these limits, Safari on start was around 160MB and it went up to 200+ MB, but most times stayed in the 170-180MB range.
My next test was to figure out the impact of PhoneGap framework. The sample Hello world application when I install phonegap and try it out already seems to be using around 100 MB (virtual memory). I tried to search on the web to determine how this footprint can be reduced but did not find anything.
My question is the following - what can I do to reduce the phonegap footprint and is it even relevant to helping reduce crashes of my application? I see other applications like Flipboard which are native using a lot less memory (60-70 MB) and was trying to understand why the basic footprint of a phonegap app is 100+ MB while this phonegap + sencha-touch based app is hovering in the 150 - 200 MB range.
Anand
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该考虑删除 PhoneGap 应用程序加载的插件数量。它由 xml 文件(Android、BB)或 plist(iOS)控制。例如,如果您不使用联系人,则不要加载该插件等。
You should look at removing the number of plugins your PhoneGap app loads. That is either controlled by an xml file (Android, BB) or by a plist (iOS). For instance if you are not using Contacts then don't load that Plugin, etc.
你说你的 Safari 应用程序大约有 160MB,所以我认为这(至少)不仅仅是电话间隙。因此,请尝试改进您的 Sencha 触摸应用程序。也许您不会销毁不使用的容器或类似的东西。查看此视频了解详细信息:https://vimeo.com/17882927
You say that your app in Safari was around 160MB so I think that's not (at least) just phonegap. So try to improve your sencha touch app. Probably you don't destroy containers you don't use or something similar. Check this video for details: https://vimeo.com/17882927
只是为了结束,转移到 Sencha 2.0 并使用 PhoneGap 2.0,内存使用量仍然在 150 ~ 200 MB 的范围内,但现在应用程序上的所有使用量我没有看到崩溃。我见过像 Flipboard 这样的应用程序消耗 350 MB 并且仍然可以工作,所以现在这不是问题。
基本的 Safari 移动浏览器占用内存在 100 ~150+ 范围内,因此我不能指望使用量会下降更多。
Just to bring closure, moved to Sencha 2.0 and using PhoneGap 2.0 the memory usage is still in the range of 150 ~ 200 MB but now with all the usage on the app I do not see crashes. I have seen apps like Flipboard consume 350 MB and still work so now this is not an issue.
The basic Safari mobile browser occupied memory in the range of 100 ~150+ and so I cannot expect the usage to come down a lot more.