内存问题 iPad 4.2 崩溃

发布于 2024-10-09 17:43:07 字数 301 浏览 2 评论 0原文

我正在开发一个从服务器接收 600-700 KB 的 XML 数据的应用程序。我必须对该数据进行一些操作,因此一旦收到数据,内存就会增加到 600 KB 到 2 MB,视图已经在应用程序中占用了 4 MB 内存。 因此,在处理 XML 数据时,我会进行一些操作(预解析),内存会增加到 600 KB 到 2 MB,最后由于内存增加而减少到 600 KB,应用程序会发出内存警告。当收到内存警告时,我释放了导航控制器中的所有视图,但它仅释放了 1 MB 内存。即使我释放了所有视图,应用程序也会崩溃。 请帮我解决这个问题。 iPad 4.2 中会出现这种情况。

提前致谢

I am developing a application which receives 600-700 KB of XML data from the server. I have to do some manipulations in that data so once received the data the memory increases to 600 KB to 2 M.B. Already view occupied 4 M.B of memory in the application.
So while processing the XML data i m doing some manipulation(pre-parsing) and the memory increases to 600 K.B to 2 M.B and finally decreases to 600 K.B. due to increase in memory, application gives the memory warning. While getting memory warning i m releasing all the views in the navigation controller but it releases only 1 M.B of memory. Even though I release all the views the application is crashing.
Please help me out in this issue. It happens in iPad 4.2.

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

舞袖。长 2024-10-16 17:43:07

这里没有神奇的答案。您使用了太多内存,需要弄清楚如何使用更少的内存。如果不了解有关应用程序的更多信息,就很难具体说明,但显然加载近 1Mb 的数据并使用它并没有帮助。

也许您可以流式传输数据而不是将其全部加载到内存中?有一个开源库可以提供帮助:StreamingXMLParser

另外,您的视图听起来很大(超过一兆字节!)。我确信可以在那里执行一些优化。使用 Instruments 查看内存的使用情况。

There's no magical answer here. You're using too much memory and you need to figure out how to use less. Without knowing more about your application it's difficult to be specific, though clearly loading in nearly 1Mb of data and playing around with it isn't helping.

Maybe you can stream the data rather than loading it all into memory? There's an open source library that helps: StreamingXMLParser.

Also, your view sounds huge (over a megabyte!). I'm sure there's some optimisation that can be performed there. Use Instruments to see where your memory is being used.

亣腦蒛氧 2024-10-16 17:43:07

也许只释放 1MB,因为参数值可以更改,或者您可能需要在开发会话期间手动启动垃圾收集操作(如果与所使用的语言相关)。如果可能的话,您可以对 xml 输入进行分段,或者如果您可以以允许的方式访问脚本或代码,则可以在存储时调用[您自己的] 压缩或压缩 xml。

Maybe only 1MB is released because of a parameter value which can be altered or you may need to manually start a garbage collection operation during your development session, if relevant to the language in use. You could sectionalise the xml input if possible or you could invoke [your own] compact or compress of the xml when stored if you have access to the script or code in a way that allows it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文