经过数小时的调试后,iOS 出现内存警告

发布于 2024-11-27 01:49:55 字数 295 浏览 2 评论 0原文

我正在创建一个 iPad 应用程序,但我发现了一些奇怪的行为。我正在立方体面上加载纹理图像,每个纹理的大小为 1024x1024px。

当我在应用程序上工作一段时间时,我在调试时收到内存警告,并且应用程序崩溃。我工作的时间越多,运行的调试会话越多,内存警告就越频繁,在最坏的情况下,每次都会触发内存警告。

当我关闭然后打开 iPad 应用程序时,它工作正常,一切都很好并且没有错误(在一段时间内......)。

当应用程序在调试时崩溃时,是否有可能不会释放内存?多次崩溃后,iPad 上有太多以前泄露的垃圾,以至于无法正常运行?

I'm creating an iPad app and I'm seeing some strange behaviour. I'm loading texture images on cube faces, each texture has size 1024x1024px.

When I work for some time over my app I'm geting memory warnings while debugging, and application crashes. The more time I work, and more debugging sessions run memory warnings are more often and in worst case memory warnings are fired every time.

When I turn off, and then turn on iPad app is working perfectly, everything is fine and there are no errors (for some period of time...).

Is it possible, that when app crashes while debugging, it doesn't free it's memory? And after multiple crashes iPad has so much garbage from previous leaks, that it cannot run normally?

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

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

发布评论

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

评论(2

风向决定发型 2024-12-04 01:49:55

您的解释似乎暗示了您的建议,即崩溃后,记忆不会完全恢复,至少不会立即恢复。不过,可能有不同的解释,即:监督内存使用情况并发送内存警告的哨兵无法在应用程序崩溃后清理其状态(至少不能立即);因此,当您启动新的调试会话时,它仍然使用旧信息,例如您的应用程序使用了多少内存,等等。

如果不了解 iOS 的内部结构,这是很困难的,但为了澄清一点,我建议安装众多免费应用程序之一,这些应用程序可以为您提供设备状态和可用内存量,这样您就会知道,在崩溃后,有多少内存记忆其实还剩下。

它也可能很有用,在您的观察中引入时间变量,或者尝试在重新启动您的应用程序之前启动不同的应用程序,或者启动您的应用程序然后杀死它......

What you explain seems to hint at exactly what you suggest, i.e., that after a crash, memory is not completely recovered, at least not immediately. There could be a different explanation, though, that is: the sentinel which supervises memory usage and sends the memory warnings is not able to clean up its state for your app after your app crashes (at least not immediately); so, when you start a new debugging session, it still uses old information as to how much memory your app is using, and so on.

Without knowing the internals of iOS it is difficult, but to clarify thing a bit I would suggest installing one of the many free applications that gives you the device status and the amount of free memory, so you will know, after a crash, how much memory is actually left.

It could be useful, also, introducing the time variable in your observations, or trying to start a different application before restarting yours, or starting yours and then killing it...

葬心 2024-12-04 01:49:55

我终于解决了这个问题;)这只是我的代码中的内存清理问题。

当我重新启动 iPad 时,它释放了一些内存,但一段时间后它又被填满,并且当我分配大位图图像时出现内存警告。然后导航控制器开始释放它的视图,并且存在一些错误导致内存无法正确清理并最终导致应用程序崩溃。

I have finally resolved this issue ;) it was just a memory cleaning problem in my code.

When I restarted iPad it freed some memory, but after some time it was filled again and when I was allocating a big bitmap image there was a memory warning. Then navigation controllers started to free it's views and there were some bugs that caused memory not clean properly and finally caused application crashes.

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