iPad 和内存问题

发布于 2024-09-28 13:00:39 字数 258 浏览 0 评论 0原文

是否有可能,当 iPad 应用程序因“内存不足”而被 iOS 强制关闭/终止时,应用程序分配的内存并未 100% 释放?我认为客户端直接分配的内存被释放 - 甚至有对此的硬件支持,但我们观察到,如果应用程序被 iOS 关闭/杀死并因此再次启动,可用内存会越来越少,直到 iPad 必须重新启动。我们认为一些内存是由后台运行的守护进程分配的,这些守护进程代表应用程序执行一些工作,如果进程间通信未成功完成,守护进程端使用的内存可能无法正确释放......

是这样的这可能吗? BR 斯坦恩

is it possible, that when the iPad application is forcibly closed/killed by the iOS becuase of 'out of memory situation', the memory the application allocated is not 100% released? I think that the memory allocated directly by the client is released - there is even HW support for this, but we were observing that if the application is closed/killed by iOS and consequently started again less and less memory is available, until the iPad must be restarted. We think that some memory are allocated e.g. by background running daemons, which do some job on behalf of application and if the inter-process communication is not successfully finished, used memory on the daemon side might not be released properly...

Is something like this possible?
BR
STeN

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

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

发布评论

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

评论(2

豆芽 2024-10-05 13:00:39

如果您分配内存,它将保留在堆中,直到您释放它,即使执行分配的应用程序早已消失。正如您所看到的,重新启动设备将清除堆。

您应该始终管理内存事件,有一个方法可以实现这一点。

- (void)didReceiveMemoryWarning;

通常,您会释放您可以释放的所有内容,尤其是在级别 2 的情况下,就好像您不释放您的应用程序无论如何都会关闭一样。

然而,当你的应用程序退出时,它应该调用 dealloc 无论如何!所以你可能有一般性泄漏。

If you alloc memory it will stay in the heap until you release it, even if the app that did the alloc is long gone. Like you have seen restarting the device will clear the heap.

You should always manage memory events, there is a method for this.

- (void)didReceiveMemoryWarning;

typically you would release everything you can, especially if its a level 2, as if you don't your app is going to close anyway.

However, When your app exits it should be calling dealloc anyway! so you may have a general leak.

花心好男孩 2024-10-05 13:00:39

我相当确定该方法:

- (void)applicationWillTerminate:(UIApplication *)application;

即使应用程序崩溃也会运行。如果没有被内存警告捕获,这将是确保所有内容都被释放的好时机。

I'm fairly certain that the method:

- (void)applicationWillTerminate:(UIApplication *)application;

will run even if the app is crashing. This would be a good time to ensure that everything is released, if it is not getting caught by the memoryWarning.

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